Apple's support information is somewhat unclear as to how to do this. This is what it says in the section When you’re ready to manage your own device from: Family Sharing overview for kids and teens - Apple Support
"Depending on your age, you may be able to leave your Family Sharing group – or you may need permission from your family organizer.
- When you turn 18, you can decide to leave your Family Sharing group or manage your own Screen Time settings."
I would contact Apple about this since to me it isn't clear if this is fully automated or if all you can do is leave the Family Sharing group and that somehow magically stops Parental controls, or neither.
Refer to this page for Apple Support features ➔ Contact - Official Apple Support
Select from the presented options until you find a solution for your issue, or see if there is a chat or phone call contact method offered lower on the page under “Get more help” (you sometimes have to narrow down the options multiple times before this is shown). If you do not see your issue, keep experimenting with any series of selections until you reach one that offers a chat session or a telephone call and get the representative to redirect you.
This support article has various country telephone numbers for contacting Apple for support and service ➔ Contact Apple Support - Apple Support Scroll down to “Connect with live support”. If your country is not in the list, go to the “Other countries” entry at the end of the list. Not every country has telephone support, and phone numbers may only work when calling from the same country.
For chat, you can try using the Apple Support App —> https://apps.apple.com/app/apple-support/id1130498044
If you get an answer then please post back with how to do this because this is a not-infrequent question!