In homogeneous coordinates, one might rotate $\theta$ around the $x$ axis by performing the following.
$\begin{bmatrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1\end {bmatrix}$
to
$\begin{bmatrix} 1 & 0 & 0 & 0\\ 0 & \cos \theta & -\sin\theta & 0 \\ 0 & \sin\theta & \cos\theta & 0 \\ 0 & 0 & 0 & 1\end {bmatrix}$
But how might one rotate around a line that is not an axis? For example for $y = x, z = 0$
If the line goes through the origin, then you can use Rodrigues’ rotation formula with a direction vector of the line as the rotation axis to construct the upper-left $3\times3$ submatrix. If it doesn’t pass through the origin, a straightforward way to proceed is to compose three transformations: a translation that puts the origin on the line, a rotation about an axis through the origin, then a translation back. The combined matrix will be of the form $$\left[\begin{array}{c|c} I & \mathbf p \\ \hline \mathbf 0^T & 1 \end{array}\right] \left[\begin{array}{c|c} R & \mathbf 0 \\ \hline \mathbf 0^T & 1 \end{array}\right] \left[\begin{array}{c|c} I & -\mathbf p \\ \hline \mathbf 0^T & 1 \end{array}\right] = \left[\begin{array}{c|c} R & \mathbf p - R\mathbf p \\ \hline \mathbf 0^T & 1 \end{array}\right].$$ Here $\mathbf p$ is any convenient point on the line and $R$ is the $3\times3$ rotation matrix generated by Rodrigues’ formula.