I am not aware of any country that has an actual law against solo diving.
However, it appears in my limited experience, that the investigating authorities look at the recommendations of training agencies. Where there is a fatality, and breaches of 'recommended practice', there is an immediate focus on the break in 'normal, or recommended practice'.
One of the reasons that private sites, and many boats do not allow solo diving, is because this increases the risk to them being having to defend themselves for 'allowing an unsafe practice', i.e. a practice that deviates from the recommend practice by the majority of 'regulating or training agencies'.
Another truism, is that, in the majority of countries there is no legal requirement to be 'trained to dive' for recreation purposes.
One worrying thing, is that the number of private legal actions taken by surviving family against other divers in a group, the charter company, the skipper and crew seems to be on the increase. I can fully understand surviving family wanting a reason why a loved one died. But there seems to be a significant lack of understanding about what their family member was doing and the risks involved.
The old phrase, its my risk, i'll solo dive. Has turned into I think it's my risk, but if I don't survive I'll leave you to defend yourself against the authorities or my family's lawyers.
If you go to a beach on your own, walk off the beach for a dive, and die. Then it was your risk, and no one else is in the frame.
If you get on a boat with other divers, then potentially, the divers on the boat, the skipper, and the charter company can all be embroiled in any subsequent investigation. So it's now their risk, that doesn't seem fair to me.
Gareth