Let's say our Lagrangian looks something like this:
$$L = \int dz\, Q\cdot \dot{A},\tag{1}$$
where $Q$ and $A$ are two generalized coordinates and $\dot{Q}$ and $\dot{A}$ would be the respective time-derivatives. If I wanted to Legendre-transform this, then considering the conjugate momenta $$P_Q = \frac{\partial L}{\partial \dot{Q}} = 0\tag{2}$$ and $$P_A = \frac{\partial L}{\partial \dot{A}} = Q\tag{3}$$ the Hamiltonian becomes:
$$H = P_Q\dot{A}-L= \int dz\,\, Q\cdot \dot{A} - Q\cdot \dot{A} = 0.\tag{4}$$
Is this correct? What does that even mean for the physical system?