How can a cylinder be rotated at any angle $\theta$ about the origin using cartesian coordinates? How can a cylinder be rotated at any angle $\theta$ at origin using cartesian coordinates?
What would be the equation for a cylinder (first figure) rotated about the origin?



The equation of a cylinder in the upright position (i.e. with its axis along the vertical $z$ axis, is given by
$ \mathbf{p}^T Q \mathbf{p} = r^2 $
where $\mathbf{p} = [x, y, z]^T $ , and $r$ is the radius of the cylinder, and the $3 \times 3$ matrix is given by
$ Q = \begin{bmatrix} 1 && 0 && 0 \\ 0 && 1 && 0 \\ 0 && 0 && 0 \end{bmatrix} $
Now, if we rotate the axis of this center about an rotation axis $\mathbf{u}$ that passes through the origin by an angle $\theta$, then the rotation matrix $R$ will be
$ R = \mathbf{u u}^T + (I - \mathbf{u u}^T ) \cos(\theta) + S_u \sin(\theta) $
$S_u = \begin{bmatrix} 0 && - u_z && u_y \\ u_z&& 0 && - u_x \\ -u_y && u_x && 0 \end{bmatrix} $
The above formula is called the Rodrigues' rotation matrix formula.
The image of a point on the cylinder $\mathbf{p}$ is the point $\mathbf{p'}$ given by
$ \mathbf{p'} = R \mathbf{p} $
From this, we have
$\mathbf{p} = R^{-1} \mathbf{p'} = R^T \mathbf{p'} $
Substitute this in the equation of the cylinder, gives you,
$ \mathbf{p'}^T R Q R^T \mathbf{p'} = r^2 $
And this is the desired equation of the rotated cylinder.
For example, if the cylinder is rotate about the $y$ axis by $45^\circ$, then the rotation matrix will be
$ R = \dfrac{1}{\sqrt{2}} \begin{bmatrix} 1 && 0 && 1 \\ 0 && \sqrt{2} && 0 \\ -1 && 0 && 1 \end{bmatrix} $
The matrix we want is $ Q' = R Q R^T$, and equals,
$ Q' = R Q R^T = \frac{1}{2}\begin{bmatrix} 1 && 0 && 1 \\ 0 && \sqrt{2} && 0 \\ -1 && 0 && 1 \end{bmatrix}  \begin{bmatrix} 1 && 0 && 0 \\ 0 && 1 && 0 \\ 0 && 0 && 0 \end{bmatrix} \begin{bmatrix} 1 && 0 && -1 \\ 0 && \sqrt{2} && 0 \\ 1 && 0 && 1 \end{bmatrix} $
Multiplying the first two matrix from the left
$Q' = \dfrac{1}{2} \begin{bmatrix} 1 && 0 && 0 \\ 0 && \sqrt{2} && 0 \\  - 1 && 0 && 0 \end{bmatrix} \begin{bmatrix} 1 && 0 && -1 \\ 0 && \sqrt{2} && 0 \\ 1 && 0 && 1 \end{bmatrix} $
Multiplying these two matrices, gives us $Q'$
$Q' = \dfrac{1}{2} \begin{bmatrix} 1 && 0 && - 1 \\ 0 && 2 && 0 \\ -1 && 0 && 1 \end{bmatrix} $
Now the equation of the rotated cylinder is
$ \mathbf{p'}^T Q' \mathbf{p'} = r^2 $
And since $\mathbf{p'} = [x, y, z]^T $, then the equation is
$ x^2 + 2 y^2 + z^2 - 2 x z = 2 r^2 $
EDIT:  However, there is an easier way to write the equation of a rotated cylinder, using its rotated axis.  Note that
$ Q = (I - \mathbf{kk}^T ) $
where $ \mathbf{k} $ is the unit vector along the $z$ axis ($\mathbf{k} = [0, 0, 1]^T$).  Therefore, the matrix for the rotated cylinder as given above is
$ Q' = R Q R^T = R (I - \mathbf{k k}^T ) R^T = I - \mathbf{a a}^T $
where $ \mathbf{a} = R \mathbf{k} $ is the rotated axis unit vector, i.e. it is the vector resulting from applying the rotation matrix to the original unit axis vector $k$.
So, now for our example, instead of all that derivation, just compute the rotated cylinder axis unit vector.  Since we're rotating the cylinder about the $y$ axis by $45^\circ$, then the new axis is
$ \mathbf{a} = R \mathbf{k} =\dfrac{1}{\sqrt{2}} [1, 0, 1]^T $
Hence,
$Q' = I - \mathbf{a a}^T = I - \dfrac{1}{2} \begin{bmatrix} 1 && 0&& 1 \\ 0 && 0 && 0 \\ 1 && 0 && 1 \end{bmatrix} = \dfrac{1}{2} \begin{bmatrix} 1 && 0 && -1 \\ 0 && 2 && 0 \\ -1 && 0 && 1 \end{bmatrix} $
which is what we got earlier.  And the same equation in $x,y,z$ follows.
EDIT 2
As another example (a general one), suppose you rotated the vector $\mathbf{k}$ using the rotation matrix $R$, or you know the orientation of the final axis $\mathbf{a}$ in space, then you can express this vector is cylindrical coordinates as follows
$ \mathbf{a} = \begin{bmatrix} \sin(\theta) \cos(\phi) \\ \sin(\theta) \sin(\phi) \\ \cos(\theta) \end{bmatrix}$
Then the matrix $Q'$ is
$ Q' = I - \mathbf{a a}^T = \begin{bmatrix} a && d && e \\ d && b && f \\ e && f && c \end{bmatrix} $
And the equation of the cylinder will be
$ a x^2 + b y^2 + c y^2 + 2 d x y + 2 e x z + 2 f y z = r^2 $
