I have read some questions (and the Wikipedia article) about the hamiltonian formulation of a QFT, but the only example that seems to be brought up is the scalar case, saying that $$\mathcal{H}_S=\Pi\partial_0\phi-\mathcal{L}_S.$$ Can I write the Hamiltonian for a general theory in the same way? For example, for Yang-Mills theory is the following true? $$\mathcal{H}_{YM}=\pi_\mu^a\partial_0W^{a\mu}-\mathcal{L}_{YM}.$$ What about for an interacting theory like Yang-Mills coupled with a scalar, can I write as follows? $$\mathcal{H}=\pi_\mu^a\partial_0W^{a\mu}+\Pi\partial_0\phi-\mathcal{L}.$$
I don't see why not, after all the two functions should exist for all these theories, and I can't think of another way to find the Hamiltonian knowing the Lagrangian.