Is there not some other way to enforce the constraint in terms of theta ?.
yes there is.
The NEWTON equations of motion are:
$$m\,\vec{\ddot{u}}=\vec{f}_a+\vec{f}_z\tag 1$$
where
$\vec{{u}}= \begin{bmatrix}
{x(\vec{q})}\\
{y(\vec{q})}\\
\end{bmatrix}\quad$
and
$\vec{q}$ the generalized coordinates
$\vec{f}_a$ applied forces include conservative forces
$\vec{f}_z$ constrained forces
the time derivative of the vector $\vec{u}$ is:
$\vec{\dot{u}}=J\,\vec{\dot{q}}$ and $\quad \vec{\ddot{u}}=J\,\vec{\ddot{q}}+\dot{J} \vec{\dot{q}}$
with:
$J=\frac{\partial \vec{u}}{\partial \vec{q}}\quad$ and
$\quad \dot{J}=\frac{\partial \left(J\vec{\dot{q}}\right)}{\partial \vec{q}}$
so equation (1) map to:
$$m\,J\,\vec{\ddot{q}}=\vec{f}_a+\vec{f}_c+\vec{f}_z\tag 2$$
with:
$\vec{f}_c=-m\,\frac{\partial \left(J\vec{\dot{q}}\right)}{\partial \vec{q}}\,\vec{\dot{q}}\quad $ Coriolis and centrifugal forces
To eliminate the constrain forces $\vec{f}_z$ from equation (2), we can write the constrained forces with a distribution matrix $C_z$ and generalized constrained forces $\vec{\lambda}$.
$\vec{f}_z=C_z\,\vec{\lambda}$
$$m\,J\,\vec{\ddot{q}}=\vec{f}_a+\vec{f}_c+C_z\,\vec{\lambda}\tag 3$$
according to d'alembert approach the product $J^T\,C_z$ must be zero
multiply equation (3) with $J^T$ yields to:
$$\boxed{J^T\,m\,J\,\vec{\ddot{q}}=J^T\left(\vec{f}_a+\vec{f}_c\right)}\tag 4$$
multiply equation (3) with $C_z^T$ yields to:
$$\boxed{\mathbb{0}=C_z^T\left(\vec{f}_a+\vec{f}_c\right)+C_z^T\,C_z\,\vec{\lambda}}\tag 5$$
equation (4) are the equations of motion for the generalized coordinates $\vec{q}$, with equation (5) you get the generalized constrained forces $\vec{\lambda}$ .
your example
generalized coordinate is $\theta$ and
$\vec{u}=\begin{bmatrix}
a\sin(\theta)\\
a\cos(\theta)\\
\end{bmatrix}$
$\Rightarrow$
$J=\begin{bmatrix}
a\cos(\theta)\\
-a\sin(\theta)\\
\end{bmatrix}$
Applied force
$f_a=\begin{bmatrix}
0\\
-m\,g\\
\end{bmatrix}$
with equation (4) we can calculate the equation of motion for the generalized coordinate $\theta$
to calculate the constrained force we have to construct the matrix $C_z$ that fulfill the equation $J^T\,C_z=\mathbb{0}$
$\Rightarrow$
$C_z=\left[ \begin {array}{c} a\sin \left( \theta \right)
\\ a\cos \left( \theta \right) \end {array} \right]
$
with equation (5) we can calculate the generalized constrained force $\lambda$