I have a line connecting pt1 {x1, y1, z1} and pt2 {x2, y2, z2} with respect to some global origin as depicted below in figure 1.
What I'm trying to do is to rotate/translate pt2 around pt1 so that the line is parallel to x-axis
I know it's a trivial problem to solve but has been a while since I've done my geometry so any help would be very welcome. I'm trying to implement this in Python so any functions/pseudo code would be great

To rotate about an arbitrary point, translate the origin to that point, rotate, and translate back. See this answer and other related/duplicate questions for details. Your problem then reduces to computing a $3\times3$ rotation matrix $R$ that brings $p_2-p_1$ onto the $x$-axis. If you search for things like “align two vectors” you should find plenty of descriptions of how to do this. Note, though, that there’s an infinite number of rotations that do what you want. After you’ve aligned the vector with the $x$-axis, you can rotate arbitrarily about this axis without affecting any vector that lies along it.
Perhaps the simplest way to construct a suitable $R$ is to set $\mathbf u={p_2-p_1\over\lVert p_2-p_1\rVert}$, $\mathbf w$ to the value of the cross product $\mathbf u\times(1,0,0)^T$, also normalized so that $\lVert\mathbf w\rVert=1$, $\mathbf v=\mathbf w\times\mathbf u$, and finally, $$R=\begin{bmatrix}\mathbf u^T\\\mathbf v^T\\\mathbf w^T\end{bmatrix}.$$ (The rows of $R$ are the three vectors computed above.) Note, though, that if $p_2-p_1$ is parallel to the $x$-axis, then $\mathbf w=0$ and you’ll have to deal with this case separately: either $p_2-p_1$ already points in the desired direction, or you’ll have to rotate it 180° about some convenient axis. In practice, due to the limitations of floating-point arithmetic vectors that are almost parallel to the $x$-axis can be problematic and will need special handling.
However, when people ask about aligning vectors like this, they’re usually interested in the minimal-angle rotation, which is not what the above produces. For that, you need to rotate about an axis that’s perpendicular to both $\mathbf u$ and $\mathbf e_1=(1,0,0)^T$. The vector $\mathbf w$ constructed above fits the bill and the order in which the cross product was performed guarantees that the rotation angle will be nonnegative. This angle is given by $\cos\theta = \mathbf e_1\cdot\mathbf u$. You can now either use Rodrigues’ rotation formula to construct the rotation matrix (with $\mathbf k=\mathbf w$) or compute the matrix product $$R_{\text{min}} = \begin{bmatrix}\mathbf e_1 & \mathbf w \times \mathbf e_1 & \mathbf w\end{bmatrix} R.$$ (The vectors form the columns of the left-hand matrix in the product.) You can verify for yourself that this maps $\mathbf u$ to $\mathbf e_1$ and leaves $\mathbf w$ fixed. After determining $\mathbf w$ and $\cos\theta$, you could instead apply Rodrigues’ rotation formula directly to all of the translated points, but for a large enough number of them, computing the combined $4\times4$ (and practically speaking, really $3\times4$) transformation matrix and multiplying the original coordinates by this matrix will be more computationally efficient. If you do decide to use Rodrigues’ formula, remember that you don’t need to compute $\theta$ explicitly: you need its sine and cosine. You have the cosine, from which you can then compute the sine directly.