Ehrenfest regularization of Hamiltonian systems