Part of the reason I'm doing a PhD in physics is, of course, because I enjoy the work. Everyday I come in and I always feel like I have something to learn from the people I work with. I feel like I grow as a person because I'm constantly learning new things from my peers - whether that be something purely theoretical, hands-on electronics work, cleanroom work, machine shop work, optics work, or, yes,
coding. Could the same be true in industry? Absolutely. Is it nearly as guaranteed? I'm sure not. I definitely have friends that are starting to gain the golden handcuffs at their companies, and they've only been working for 2 years.
Moreover, I don't think it's fair to say that people waste their time doing a PhD in physics. Sure, they could be learning a lot more job-specific skills, but the point is that the people who do a PhD in physics absolutely have the ability to learn those things. I'm sure if the physicist used PCA it wouldn't take him long to learn plenty of other ML techniques. I think the skills you learn during a PhD aren't as simple as just listing out the technical things you became familiar with. (Still, I'm certainly considering leaving grad school, but I don't think it's an obvious decision.)
Of course, I think there is a lot more to a job than the technical skills you bring to the table --- your ability to communicate, your understanding of the market & product, and your ability to work well with others. (Yes, I'm fully aware physics people don't often hold gold medals in these categories). I think that doing an internship could help in these respects, and it's why I'm interested in doing one.