If you are having problems with some of your accounts in Office 365 where you have had to modify the name of an on-premise user but it’s not updating the login name of the user once an AD-Sync has completed, you can run this script below to give the user new UPN in Office 365
$currentUPN = <Users Current UPN>
$newUPN = <Users New UPN>
Get-MSolUser -UserPrincipalName $currentUPN
Set-MSolUser -UserPrincipalName $currentUPN -NewUserPrincipalName $newUPN
Get-MSolUser -UserPrincipalName $newUPN
No errors should be seen when running this script if all works okay.