Finite-size scaling in Hamiltonian field theory