Does a Lagrangian always generate a unique Hamiltonian?
In general, the mapping defined by $$ p_i(q,\dot{q}) = \frac{\partial L}{\partial \dot{q}^i}$$ is neither injective nor surjective. Theories in which it is not are constrained Hamiltonian theories and equivalently Lagrangian gauge theories in which the solutions to the equations of motion contain arbitrary functions of time. "Constrained" means that the $q$ and $p$ are not independent after the transformation and that there are primary constraints $\phi_i(q,p) = 0$ among them that hold off-shell.
The map is (locally) invertible if and only if $$ \mathrm{det}\left(\frac{\partial L}{\partial \dot{q}^i \partial \dot{q}^j}\right) \neq 0$$ for all $(q,\dot{q})$.
In the Lagrangian world this can be seen because the accelerations $\ddot{q}^i$ are determined uniquely by pairs $(q,\dot{q})$ if and only if this is true, otherwise we have gauge degrees of freedom because $$ \ddot{q}^j\frac{\partial L}{\partial \dot{q}^i \partial \dot{q}^j} = \frac{\partial L}{\partial q^i} - \dot{q}^j\frac{\partial L}{\partial \dot{q}^i \partial q^j},$$ which follows from the Euler-Lagrange equations, can be solved for $\ddot{q}$ uniquely only if $\frac{\partial L}{\partial \dot{q}^i \partial \dot{q}^j}$ is invertible.
When there are constraints, the Hamiltonian $$ H = \dot{q}^i p_i - L$$ is not unique in the sense that it is uniquely determined only on the physically relevant constraint surface in phase space defined by the $\phi_i(q,p) = 0$. The transformation $$ H \mapsto H + \phi_i(q,p)f^i(q,p)$$ for arbitrary functions $f^i$ leaves the physics unchanged since the additional term vanishes off-shell on the constraint surface. Hence the Hamiltonian associated with a Lagrangian with gauge freedom is not unique.
In general, if you have a nonstandard kinetic term, it may be impossible to transform the equations of motion from Lagrangian to Hamilton form. Probably the simplest situation of this type (following an example from Nambu) is if the kinetic energy $K$ is a quartic function of the velocity. The fourth power makes $K$ bounded below (as it should be), and it is possible to have quasiparticles in condensed matter systems with this kind of kinetic energy.
The key point is that the definition of the canonical momentum, $$p=\frac{\partial L}{\partial\dot{q}}$$ is a cubic polynomial to solve for $\dot{q}(p)$. Unlike the linear equation that results when $K=\frac{1}{2}m\dot{q}^2$, the cubic equation does not have a unique solution, so it is not possible to have a unique Hamilton.
You might think that you could get around this difficulty by selecting one root if the cubic equation and sticking with that. However, that too fails. If you solve the Lagrangian equations of motion, you will find that the velocity $\dot{q}$ will generally not stay on the same branch of solutions of the cubic.
The key equation to get the Hamiltonian is this one:
$$\vec{p}-\underbrace{\frac{\partial L(\vec{q}\,,\vec{\dot{q}})}{\partial \vec{\dot{q}}}}_{\vec{f}(\vec{q},\vec{\dot{q}})}=0\tag 1$$
we have to solve equation (1) for $\vec{\dot{q}}=\ldots$
to solve equation (1) we take the Taylor series an get:
$$\Delta{\vec{p}}-\vec{f}(\vec{q}_0,\vec{\dot{q}}_0)-\frac{\partial \vec{f}}{\partial \vec{\dot{q}}}\bigg|_{\left(\vec{q}_0,\vec{\dot{q}}_0\right)}\Delta{\vec{\dot{q}}}=0\tag 2$$
thus :we get unique solution for $\Delta{\vec{\dot{q}}}$ only if die determinate of the $(n_q\times n_q)$ matrix $\quad \frac{\partial \vec{f}}{\partial \vec{\dot{q}}}\quad $ is not equal zero
this is the condition to have unique Hamiltonian
for all conservative system you get unique Hamiltonian, because the Hamiltonian is equal the energy of the system
Example:
$$L=\frac{1}{2}\,m{r}^{2} \left( {{\it\dot{q}}_{{1}}}^{2}+{{\it\dot{q}}_{{2}}}^{2} \right) -{\it mg} \left( r\sin \left( q_{{1}} \right) +r\sin \left( q _{{2}} \right) \right)$$
$\Rightarrow$
$$\vec{f}=\left[ \begin {array}{c} m{r}^{2}{\it\dot{q}}_{{1}}\\ m {r}^{2}{\it\dot{q}}_{{2}}\end {array} \right]$$
and
$$\frac{\partial \vec{f}}{\partial \vec{\dot{q}}}=\left[ \begin {array}{cc} m{r}^{2}&0\\ 0&m{r}^{2} \end {array} \right] $$ where :
$$\vec{\dot{q}}= \left[ \begin {array}{c} \dot{q}_{{1}}\\ \dot{q}_{{2}} \end {array} \right] $$ thus:
$$\det\left(\frac{\partial \vec{f}}{\partial \vec{\dot{q}}}\right)\ne 0$$ the Hamiltonian exist!