When Azure AD Connect it configure to sync ad account to Azure AD/Office 365 it assigns the login name as the AD UPN (as expected), but it won’t assign that same UPN as the default email address – instead it assign a @mydomain.onmicrosoft.com as the primary email address.
to correct this we can use the Synchronization rules editor, which is installed together with the Azure AD Connect (Download Link)
In Synchronization rules editor, switch the direction tabs to outbound rules.
select the rule called “Out to ADD – UserExchangeOnline”, click edit and accept the option to disable and clone the rule (this will create a rule called ““Out to ADD – UserExchangeOnline – Cloned” that can be modified.
Change the precedence to 50
go to transformations, and Scroll down till you find the “Target Attribute” of “ProxyAddresses”
Change the FlowType to “Expressions” and enter the following in the source:
"SMTP:" & [userPrincipalName]
Now resync the users and the primary email address should be changed
Sources: https://rscc.co.uk/solution-office-365-assigning-onmicrosoft-com-addresses-used-aad-connect/