Most residents at academic programs will be employed by either the state, the medical school (mostly non-profit,) or the hospital (mostly 501c3 non-profit,) and thus most residents qualify for PSLF. There are also community programs at non-profit hospitals where the residents are direct employed by the hospital, and they also would qualify. I know this because I got credit for my residency and have networked with many physicians in many programs who also got credit for theirs.
There are many 501c3 hospitals and it is possible to be a direct employee of such a hospital. I was one and got PSLF recently. However, in many cases, physicians who work at these hospitals are actually employed by a for profit physician group, which will not qualify. The EIN on your paycheck has to correspond to a government or nonprofit organization.
Working as an attending at most academic institutions and all governmental institutions will qualify.
I've heard a million times in the last ~12 years how I won't get PSLF, it doesn't work, its going to be taken away, etc etc etc. But I just had $470k discharged official today and it really wasn't that hard to arrange, with a little self education re the program and some careful choices about my training and post residency work.