To change your PSN Online ID, go to playstation.com and sign in. Click your profile icon in the top-right corner and select Edit Profile. Click on your Online ID and enter your new one. Alternatively on PS5 go to Settings → Users and Accounts → Account → Online ID and enter your new ID. Important things to know before changing:
Your first change is free — after that each change costs $4.99 / £3.99
Your old Online ID will be displayed alongside your new one for a period of time so friends can still find you
Most games fully support Online ID changes but some older PS3, PS4, and PS Vita games may have issues such as lost progress, in-game items, or features not working correctly