Every app submitted to the App or Play store already has to do this. If parental controls are on, then users cannot download those apps.
The only hard part for the web is that a site could lie since there is no gatekeeper, but some black lists can help with bad actors.
Do the app stores have per-country rules to decide a rating?
Maybe certain headers could be cryptographically signed. So like if your movie is rated PG by the MPA the MPA itself could sign a statement to that effect. Or a government could issue a social media company a license they could use to sign their pages as complying with some regulation and revoke their license if they don't comply.