By transforming into a frame moving in the $y$-direction with the proper speed (i.e., the speed of the particle in the $y$-direction), we can make the particle's $y$-momentum be zero.
Working (like you) in units with $c=1$, the Lorentz transformation matrix for a boost to velocity $v\hat y$ looks like
$$\begin{pmatrix}
\gamma & 0 & -\gamma v & 0 \\
0 & 1 & 0 & 0 \\
-\gamma v & 0 & \gamma & 0 \\
0 & 0 & 0 & 1
\end{pmatrix}
$$
where
$$\gamma=\frac{1}{\sqrt{1-v^2}}$$
and the row and column order is $t,x,y,z$.
This matrix can transform any contravariant four-vector, such as one containing the coordinates $(t,x,y,z)$ or one containing the energy and momentum, $(E,p_x,p_y,p_z)$.
You want the energy-momentum four-vector to transform so that the $y$-momentum becomes zero:
$$
\begin{pmatrix}
E' \\
p\sin\theta \\
0 \\
p\cos\theta
\end{pmatrix}
=
\begin{pmatrix}
\gamma & 0 & -\gamma v & 0 \\
0 & 1 & 0 & 0 \\
-\gamma v & 0 & \gamma & 0 \\
0 & 0 & 0 & 1
\end{pmatrix}
\begin{pmatrix}
E \\
p_x \\
p_y \\
p_z
\end{pmatrix}=
\begin{pmatrix}
\gamma(E-v p_y) \\
p_x \\
\gamma(p_y-v E) \\
p_z
\end{pmatrix}.
$$
From the third row we find that $v$ must be
$$v=\frac{p_y}{E}.$$
From this and the other rows, we get the transformed energy-momentum parameters,
$$E'=\frac{E-\left(\frac{p_y}{E}\right)p_y}{\sqrt{1-\left(\frac{p_y}{E}\right)^2}}=\sqrt{E^2-p_y^2},$$
$$p=\sqrt{p_x^2+p_z^2},$$
and
$$\theta=\tan^{-1}\left(\frac{p_x}{p_z}\right).$$
As a check on this calculation, you can see that the invariant length of the new energy-momentum four-vector, $E'^2-p^2$, is equal to the invariant length of the old one, $E^2-p_x^2-p_y^2-p_z^2$.
Note: I have kept your somewhat-confusing notation where $p$ is the magnitude of the transformed momentum. It would be better to call it $p'$ and the angle $\theta'$.
If you are doing research in particle physics, I encourage you to become comfortable performing Lorentz transformations of energies and momenta. The general form of a boost matrix can be found here, but the special cases for boosts along the axes are simple enough to memorize. They mix only that one spatial dimension with time, and they do so in a nicely symmetrical way.