In classical mechanics, given a Lagrangain $L(x , \dot{x})$, the equations of motion are given by
$$ \frac{d}{dt} \frac{\partial L}{\partial \dot{x}}=\frac{\partial L}{\partial x} $$
If we define the Hamiltonian via Legendre transformation to $H (x,p) = p \dot{x}(p) - L(x,\dot{x}(p))$, where $ p = \partial L/\partial \dot{x}$, we have the equations of motion
$$ \dot {x} = \frac{\partial H}{\partial p }, \quad \dot{p}=-\frac{\partial H}{\partial x}.$$
Is this a special case of a more general result? i.e. if I have a differential equation $ \mathcal{L} f(x,y) = 0$, where $\mathcal{L}$ is some differential operator, then if I define the Legendre transformation $g(x,p) = py(p) - f(x,y(p))$, where $p = \partial f/\partial y$, is there a corresponding differential equation $\mathcal{L}' g(x,p) = 0 $ that the Legendre transformation satisifes, for some new differential operator $\mathcal{L}'$, or a pair of eqations, such as for the case of a Lagrangian vs. Hamiltonian?