I was sure it's going to be trivial to do, but then got stuck.
Problem - given a vector $u\in\mathbb{R}^d$ in $d$ dimensions, find a rotation matrix $M$, such that
- (Rotation) $M^T=M^{-1}$,
- (Rotation) $\det(M) = 1$,
- $Mu = \lambda\cdot(1,0,\dots, 0)^T$, for some scalar $\lambda > 0$.
That is, $M$ aligns $u$ with the $\hat{x_1}$ vector.
(Presumably $d>1$ and $u$ is not a scalar multiple of $(1,0,\ldots,0)^\top$, otherwise simply take $M=I$.)
The systematic way:
The quick and dirty way: