Say you end up with a wrong UserPrincipalName for an MSOL account which is sync’ed from On-Prem Active Directory like this: email@example.com, Which is obviously wrong UPN. The correct UPN supposed to be like firstname.lastname@example.org and it should match the user’s PrimarySMTPAddress.
I am sure you tried to correct it in Office 365 Admin Center, where UPN is grayed out. You may have tried MSOL PowerShell command Set-MSOLUser which does not have the parameter -UserPrincipalName. Right? That why you are here.
Solution: Easy Peacy. You have to use the another MSOL PowerShell command like this:
Set-MsolUserPrincipalName -UserPrincipalName email@example.com -NewUserPrincipalName firstname.lastname@example.org
That’s it. You have done it. Have an coffee! You deserve it! 🙂