Public service loan forgiveness (PSLF) exists and a huge number of people in medical professions actually take advantage of it. I know of multiple medical students and residents with over $500k in debt that are in the process of having all of their loans forgiven after 10 years in training and a total cost of approximately $75–150k for their entire education. Sure, that's still a decent amount of money, but it's very much worth the ROI.
IIUC, there was a bit of a scandal where the companies the DoE where paying to manage those 10 year forgiveness plans where giving incorrect advice and so a lot of people aren't going to qualify.
Lots of hospitals are nonprofits, and doctors can make lots of money working at hospitals. There is no income cap for PSLF IIRC, as long as you're working for a qualifying entity (including nonprofits).
Anecdotally, it's worked out for a number of friends and people on /r/PSLF. There's definitely poor communication around PSLF, but it is a real program.
https://en.wikipedia.org/wiki/Public_Service_Loan_Forgivenes...