Solution (source code)

= Solution

The map sends $|0\rangle$ to $|0\rangle$, $|1\rangle$ to $|2\rangle$, and $|2\rangle$ to $\lambda|1\rangle$. These output columns are mutually <orthogonal>, with squared <norms> $1,1,|\lambda|^2$. Consequently
$$
M_\lambda^\dagger M_\lambda=\operatorname{diag}(1,1,|\lambda|^2),
$$
and
$$
\boxed{M_\lambda\text{ is unitary if and only if }|\lambda|=1,\text{ equivalently }\lambda=e^{i\theta}\text{ for real }\theta.}
$$
Necessity follows from preserving the <norm> of $|2\rangle$; sufficiency follows because the three columns are then an <orthonormal basis>. Merely requiring $\lambda\ne0$ would establish invertibility but not <unitarity>. This is the <weighted permutation unitarity criterion>.