Kepler's First Law in 2D polar is
$$ r = \frac{p}{1 + \varepsilon\cos(\nu)}. $$
How can this be written to consider ellipses in 3D?
I am trying to plot two ellipses in Python that are in different planes so I can use the 2D polar form to plot one ellipse, but I don't know how to adjust the equation to consider an angle change in the z direction.
In 3D, an ellipse still lies in some plane, just this plane may not be $xy$-plane anymore, if you parametrize the ellipse using the polar coordinates on that specific plane, then the equation you obtain will still be $r = \dfrac{p}{1 + \varepsilon\cos\theta}$.
Now $r$ is the standard Euclidean distance to the center $\mathbf{p}_0 = (x_0,y_0,z_0)$ of this ellipse, $\theta$ is the polar angle between the position vector $\mathbf{p}-\mathbf{p}_0 = \langle x-x_0,y-y_0,z-z_0\rangle$ and the major axis vector $\mathbf{a}$ with length $a$. Let the normal to the plane be $\mathbf{n}=\langle n_1,n_2,n_3\rangle$, then the minor axis vector can be computed as $\mathbf{b} = \dfrac{\mathbf{n}\times \mathbf{a}}{|\mathbf{n}\times \mathbf{a}|}b$. And the equation should be: $$ |\mathbf{p}-\mathbf{p}_0| = \sqrt{(x-x_0)^2 + (y-y_0)^2 + (z-z_0)^2}= \dfrac{p}{1 + \varepsilon\cos\theta}, $$ where $$\theta = \operatorname{atan2}\big(\mathrm{Proj}_{\mathbf{a}}(\mathbf{p}-\mathbf{p}_0), \mathrm{Proj}_{\mathbf{b}}(\mathbf{p}-\mathbf{p}_0) \big),$$ which is the atan2 of projections of the position vector $\mathbf{p}-\mathbf{p}_0$ onto the major axis vector $\mathbf{a}$ and minor axis vector $\mathbf{b}$ respectively. Also the point on this ellipse must satisfy the constraint: $$ \mathbf{n}\cdot(\mathbf{p}-\mathbf{p}_0) = n_1(x-x_0)+n_2(y-y_0)+n_3(z-z_0) =0, $$ which means the ellipse is living on this plane with normal $\mathbf{n}$.
Other than this natural extension, you can view ellipse in 3D as the intersection curve between a cylinder and a plane. The rotation of the plane can be represented by a rotation matrix. For example, if we rotate some object about the $z$-axis by $\alpha$ counter-clockwisely, then the original $(x,y,z)$ on this object becomes: $$ \begin{pmatrix} \cos\alpha & -\sin\alpha & 0 \\ \sin\alpha & \cos\alpha & 0 \\ 0 & 0 &1 \end{pmatrix} \begin{pmatrix} x\\ y \\ z \end{pmatrix} = \begin{pmatrix} x\cos\alpha - y \sin\alpha\\ x\sin\alpha + y\cos\alpha \\ z \end{pmatrix}.\tag{1} $$ For example the plane spanned by the original major axis and minor axis vectors $\mathbf{a} = \langle a,0,0\rangle$ and $\mathbf{b}= \langle 0,b,0\rangle$ can be parametrized using two parameters $u,v$: $$ \langle x-x_0,y-y_0,z-z_0\rangle = u \mathbf{a} + v \mathbf{b}, $$ i.e., $$ \begin{cases} x = x_0 + u a_1 + v b_1 \\ y = y_0 + u a_2 + v b_2 \\ z = z_0 + u a_3 + v b_3 \end{cases} $$ then we can transform this plane by rotation around $x$-, $y$-, or $z$-axis, by matrix in (1), plugging the new $x',y',z'$ obtained to any cylinder equation $(x-p)^2 + (y-q)^2 = r^2$ you will get a 3D ellipse as well.