Lagrangian for a Central force problem is:
$$\mathcal{L} = \frac{1}{2}\mu(\dot{r}^2 + r^{2}(\dot{\theta}^{2} + sin^{2}\theta\cdot \dot{\varphi}^{2})) - U(r)$$
We know that angular momentum is defined as: $$\overrightarrow{L} = \mu \cdot \overrightarrow{r} \times \dot{\overrightarrow{r}}$$ $\therefore \hspace{0.5cm} \overrightarrow{r}(t)\cdot \overrightarrow{L} = 0, \hspace{0.5cm}$it means motion takes place in single plane.
By the coordinate transformation we can have motion in x-y plane. Therefore, it means that we have angular momentum in $\hat{Z}$ direction.
$$\therefore\hspace{0.5cm} \theta = cos^{-1}\bigg( \frac{\overrightarrow{L}\cdot \hat{Z}}{||\overrightarrow{L}||}\bigg)$$ where, $$\overrightarrow{L} = \mu \cdot r^{2}\bigg(-\big(\dot{\theta}\cdot \sin\varphi\hspace{0.1cm}+ \hspace{0.1cm} \frac{1}{2}\cdot\varphi\cdot \sin2\theta\cdot\cos\varphi)\hat{X}\hspace{0.1cm} + (\dot{\theta}\cdot \cos\varphi\hspace{0.1cm}- \hspace{0.1cm} \frac{1}{2}\cdot\varphi\cdot \sin2\theta\cdot\sin\varphi)\hat{Y} \hspace{0.1cm}+\hspace{0.1cm} \big(\dot\varphi\cdot\sin^{2}\theta\big)\hat{Z}\bigg)$$ and, $$||\overrightarrow{L}|| = \mu\cdot r^{2}\big(\dot\theta^{2}+\dot\varphi^{2}\sin^4\theta\big)^{1/2}$$
$$\implies \theta = cos^{-1}\Bigg( \frac{\dot\varphi\cdot\sin^{2}\theta}{\big(\dot\theta^{2}+\dot\varphi^{2}\sin^4\theta)^{1/2}}\Bigg)$$
I am not able to how to transform coordinate such that new Lagrangian becomes ,
$$\mathcal{L}_{eff} = \frac{1}{2}\mu\big(\dot{r}^2 + r^{2}\dot{\varphi}^{2}\big) - U(r)$$