This is exactly why it's impossible to have a program where it's possible to opt out. And if you're forced to buy it, it's probably unconstitutional (IMO). What a fucking quagmire.
As you point out, it is not possible for an medical insurance program to work if people have the opportunity to opt out. This is because, despite the example used above, most folks who choose to opt out will do so because they are healthy and don't feel they need medical insurance. Realistically, all medical insurance plans rely on having a pool of healthy non-users in the plan to offset those who have high needs health issues.
Before I retired, my employer provided my health care coverage. As my employer had a large pool of employees, they were able to be self-insured for medical insurance. I sat on the Benefits Committee. We were charged with the responsibility of making decisions which affected all employee benefits, such as rates and coverage levels. Our rates were sometimes adversely affected by just one or two folks with major medical needs even though there was a large pool of healthy people in the plan.
No matter how big the "pool" is, there must be a certain number of folks paying for coverage who are low users of the benefits. That is just how insurance works, be it medical, auto, homeowners or what have you. Of course, if you are among the wealthy, you could risk paying your own medical costs or simply purchase and "umbrella" plan that only kicks in if there is a catastrophic occurrence. One problem with not having medical insurance though is that all insurance providers contract with physicians, pharmacies, labs and hospitals for reduced rates. If you do not have coverage, you are on your own to bargain for rate reductions.