To change UPN suffix values for a selected set of Active Directory users, start with a security group that contains the intended accounts. This archived PowerShell example scopes the update to that group.
Check the target membership
Check the membership before you change UPN suffix values. Record current sign-in names so you can compare the results and investigate discrepancies after sync.

You have completed the domain work in relation to your O365 tenancy, however the usernames replicated to AAD are in “username@old suffix.com” format.
Most organizations have inherited a “username@old-domain.local” suffix. Time goes on and the organization changes its name, amalgamates, etc, for whatever reason, effectively changes its name.
The following script will serve to allow you to run the script ad hoc in order to change the full upn for the usernames in the group with from “username@old-company.local”(no joke intended), through to “firstname.lastname@new-domain.com” format:
param([string] $group)
cls
Import-Module ActiveDirectory
$newsuffix = "new-suffix.com"
$users = get-adgroupmember -Identity $group |Get-ADUser
write-host "The following users are going to be renamed, would you like to procees?"
$users.userprincipalname
write-host "The above UPNs are affected." -ForegroundColor Red
$confirmation = Read-Host "Are you Sure You Want To Proceed (y) to firstname.lastname@new-domain.com format"
if ($confirmation -eq 'y') {
foreach ($user in $users)
{
Set-ADUser -Identity $user.SamAccountName -UserPrincipalName "$($user.GivenName).$($user.Surname)@$newsuffix"
}
}
Sleep 5
Get-ADGroupMember $group | get-aduser | select userprincipalname
Related reading on this site: Automated PowerShell Script for Updating UserPrincipalNames in Active Directory After Domain Change.


