$$L~=~ \frac{1}{2} \dot{q} \sin^2{q} $$
Is it zero or not defined?
$$L~=~ \frac{1}{2} \dot{q} \sin^2{q} $$
Is it zero or not defined?
Legendre transformation. OP's question contains some subtle aspects that we would like to illuminate. Note that a Legendre transformation (singular or not) should be an involutive operation. (It would therefore be inconsistent to propose, say, that a Lagrangian, that leaves everything undetermined, should correspond to a Hamiltonian, that fixes everything. In particular, it is an oversimplification to claim that the Hamiltonian is identically zero.)
In this answer we give a consistent Legendre transformation in the framework of Dirac-Bergmann theory & constrained dynamics.
Lagrangian formulation. OP's Lagrangian reads $$ L(q,v,t)~:=~ vf(q), \qquad f(q)~:=~\frac{\sin^2 q}{2}~\stackrel{(2)}{=}~F^{\prime}(q). \tag{1}$$ The corresponding action is invariant under time-reparametrizations. But even more strikingly, it is a boundary action: $$ S[q]~=~\int_{t_i}^{t_f}\! dt~ L(q,\dot{q},t)~\stackrel{(1)}{=}~ F(q(t_f)) - F(q(t_i)), \qquad F(q)~:=~\frac{q}{4}- \frac{\sin 2q}{8}. \tag{2} $$ To have a well-defined variational problem, we should impose boundary conditions. We will assume Dirichlet boundary conditions $$ q(t_i)~=~q_i \quad\text{and}\quad q(t_f)~=~q_f. \tag{3}$$ We see that the action (2) has an infinitesimal gauge symmetry of the form $$ \delta q(t) ~=~\varepsilon(t)\quad\text{where}\quad \varepsilon(t_i)~=~0 \quad\text{and}\quad \varepsilon(t_f)~=~0.\tag{4}$$ The position $q$ is not a physical observable except for the boundary points. The Euler-Lagrange (EL) equation is identically satisfied. The Lagrangian momentum is $$ p~=~\frac{\partial L}{\partial v}~=~f(q),\tag{5} $$ and the Lagrangian energy function $$ h~=~pv-L~\stackrel{(1)+(5)}{=}~0\tag{6} $$ vanishes identically.
Hamiltonian formulation. According to the Dirac-Bergmann analysis, the eq. (5) is a primary constraint $$ \chi~:=~p - f(q)~\approx~0.\tag{7} $$ In fact, eq. (7) is a first class constraint, which generates the gauge symmetry (4) via the Poisson bracket $$ \delta ~=~\varepsilon \{ ~\cdot~, \chi\},\tag{8}$$ i.e. as a Hamiltonian vector field. The corresponding Hamiltonian action is $$ S_H[q,p,\lambda]~=~\int_{t_i}^{t_f}\!dt~ L_H , \qquad L_H ~=~p\dot{q} - H, \tag{9}$$ with Hamiltonian $$ H~:=~ \lambda \chi,\tag{10}$$ where $\lambda$ is an undetermined Lagrange multiplier, which imposes the constraint (7). The 3 EL equations for the Hamiltonian action (9) wrt. the 3 variables $\lambda$, $p$, and $q$ are Hamilton's equations $$\dot{p}~\approx~-\frac{\partial H}{\partial q}~=~\lambda f^{\prime}(q).\tag{11}$$ $$ \dot{q}~\approx~\frac{\partial H}{\partial p}~=~\lambda, \tag{12}$$ and the constraint (7), respectively. Note that eq. (11) is a consequence of eqs. (7) & (12). Also note that the Hamiltonian (10) is zero on-shell. The fact that $\lambda$ is undetermined reflects the fact that $q$ is an unphysical gauge variable.
Comparison. We can complete the square of the Hamiltonian Lagrangian (9) as $$ L_H ~= ~(p - f(q)) (\dot{q} - \lambda) + L(q,\dot{q},t).\tag{13} $$ Therefore if we integrate out the variables $p$ and $\lambda$ in the Hamiltonian action (13), we get back the original Lagrangian (1), which we started from. This is a consistency check that we have found the correct Hamiltonian formulation.
The Hamiltonian is undefined. Converting a Lagrangian to a Hamiltonian requires:
For the third step to be possible, you need to be able to define a coordinate transformation between the $(q,\dot q)$ coordinate system and the $(q,p)$ coordinate system. This requires that $(q,p)$ is a good coordinate system, in that a state of the system can be uniquely represented by a pair of $(q,p)$ coordinates. In turn, this means that the transformation $(q,\dot q)\rightarrow (q,p)$ must have nonzero Jacobian.
However, it's easy to see this is not the case. We know that $(q,p)=(q,\frac{1}{2}\sin^2 q)$. Thus, the Jacobian is
$$ J=\left|\begin{smallmatrix}1 & 0\\\sin(q)\cos(q) & 0\end{smallmatrix}\right| = 0 $$
That means we CAN'T write $p$ as a function of $q,\dot q$, and there can't be a Hamiltonian $H(p,q)$ that is a function of only the coordinates $(p,q)$ because the coordinates $(p,q)$ don't specify the state of the system.
for
$$\mathcal L=\frac{1}{2}\,f(q~,\dot q)$$
the Hamiltonian is
$$2\,H= \left( {\frac {\partial }{\partial {\dot q}}}f \left( q,{\dot q} \right) \right) {\dot q}-f \left( q,{\dot q} \right)\tag 1$$
take arbitrary function $~f(q~,\dot q)=f(q)\,\dot q~$ you obtain from equation (1)
$$\frac{\partial (f(q)\,\dot q\,)}{\partial \dot q}\,\dot q=f(q)\,\dot q\quad\Rightarrow\\ 2\,H=f(q)\,\dot q-f(q)\,\dot q=0$$
the Hamiltonian is zero
The Lagrangian given is homogeneous of degree $\color{red}{1}$ in $\dot{q}$, that is, $L(q,\lambda\dot{q})=\lambda L(q,\dot{q})$ for any $\lambda>0$. Thus by Euler's homogeneous function theorem, we have
$$\dot{q}\frac{\partial L}{\partial\dot{q}}=\color{red}{1}\cdot L=L\implies\dot{q}\frac{\partial L}{\partial\dot{q}}-L=0$$
Hence the Hamiltonian vanishes identically.