I'm not sure we do have an obligation to accept medicare or medicaid. However, from an economic perspective, it is absolutely correct that the public does not benefit enough from their tax dollars paying for residency training. Personally, I don't believe that medicare should be funding residency spots. Just make it so residents can bill insurance and the problem is mostly solved. Judging by the recent expansion in residency programs, many hospitals also see the advantage of paying minimum wage for residents without sucking on the government's teat (most of these new positions have not come from medicare funding).
I do believe we should be giving back in some way, however there are many ways to do this. That could include teaching students and residents, doing some low bono or pro bono work, working sometime in the public sector or with marginalized groups, doing some case consultation, doing community engagement or doing talks for the public on mental health, immigration evaluations etc.
There are also many public positions that do not require one to accept medicare (e.g. working at the VA, jails, prisons, state hospitals) in which a significant minority of psychiatrists work.