From your examples it seems that you are looking for a rotation that rotates the vector $(1,0,0)$ to some given unit vector $(x,y,z)$. This indeed doesn't define a unique rotation. However, the rotation with the smallest angle of rotation can in most cases be defined uniquely. If desired one could always apply an additional rotation with as rotation axis the $(x,y,z)$ vector. This shortest rotation can be found using the dot and cross products, which gives
\begin{align}
\cos \theta =& (1,0,0) \cdot (x,y,z) = x, \\
n \sin\theta =& (1,0,0) \times (x,y,z) = (0,-z,y),
\end{align}
with $\theta$ the (smallest) angle of rotation and the $n$ the unit axis of rotation.
A unit quaternion, used to describe such rotation can be defined with $\theta$ and $n$ using
$$
q = \left(\cos\theta/2,n\sin\theta/2\right).
$$
In order to evaluate the sine and cosine of half the angle one could first calculate $\theta$ for example using the atan2 function. However, one could also use the following mathematical identities
\begin{align}
\cos \theta/2 =& \sqrt{(1+\cos\theta)/2}, \\
\sin\theta/2 =& \frac{\sin\theta}{\sqrt{2\,(1+\cos\theta)}}.
\end{align}
Substituting this together with the dot and cross products in the unit quaternion expression yields
$$
q = \left(\sqrt{\frac{1+x}2},0,\frac{-z}{\sqrt{2\,(1+x)}},\frac{y}{\sqrt{2\,(1+x)}}\right).
$$
The identities used do have some sign discrepancies, but when multiplying a unit quaternion by minus one yields another unit quaternion which represents the same rotation. The only thing you need to watch out for is when $x$ is equal (or sufficiently close) to minus one. In that case you could pick any axis perpendicular to the x-axis and rotate around that with 180°.