Diffusive systems coupled to an oscillator: a Hamiltonian formulation