Hi @RSahi ,
There isn't currently a way to remove the # sign. The “#” is a reserved character in UPNs for Microsoft Entra B2B collaboration or external users, because the invited account ******@contoso.com becomes user_contoso.com#EXT#@fabrikam.onmicrosoft.com. The guest user principal name contains the #EXT# identifier.
https://learn.microsoft.com/en-us/entra/external-id/what-is-b2b
Note that UPN is not the value that links on-premises and cloud objects. That role is played by the sourceanchor (objectGUID by default). There are some workarounds mentioned in this thread that may suit your scenario, depending on where you are synchronizing the users. For example, you could use automatic user registration or import the members from a file.
As a sidenote, if you just need to query a B2B user using the userPrincipalName, you can encode the hash (#) character by replacing the # symbol with %23.
If the information helped you, please Accept the answer. This will help us as well as others in the community who may be researching similar questions. Otherwise let me know if you have further questions.