I recently found out that it is possible to formulate a Hamiltonian for a system with time-dependent coordinates such that the Hamiltonian is not the same as the energy When is the Hamiltonian of a system not equal to its total energy? and that has me wondering if it is possible to formulate a Hamiltonian for a damped system under these conditions. I know that Hamilton's equations require that energy be conserved, but if the coordinates are time-dependent, would it still be possible to formulate and solve the problem?
I started trying to do it for a damped simple harmonic oscillator by starting with the Lagrangian for the system
$$L=e^{\gamma * t}*(\frac{mv^2}{2}-\frac{kx^2}{2}),$$
but I keep on coming up with a Hamiltonian that is just equal to the energy
$$H=e^{\gamma * t}*(\frac{mv^2}{2}+\frac{kx^2}{2}).$$