You should be able to do this. Here is a knowledge base link: https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/rename-organization?view=azure-devops&source=recommendations
You need to buy the new domain name and then register it in your MS 365 account (I am assuming that is what you have because you are on this forum). MS365 should prompt you to verify ownership by adding at least a TXT record at the domain registrar. Most likely more DNS records will be necessary such as MX for mail, SPF, CNAME, and autodiscover too. These will be shown in MS365. Once you have all of the DNS records properly entered at the register (example of register is GoDaddy) you can check the health of the domain sync with MS365 by clicking the "check health". It will give you a green check. I recommend you then go back to the main domain page and make the new domain the default domain (you can have more than 1 domain in MS 365 but there can be limits what you can do if the domain is not the default). Once the domain is good to go the next step is to now you go back to Users to change the emails. To do this you have two choices: 1- edit the existing users to the new domain. Under the Username, edit, primary email address, and change the domain. I believe MS will automatically alias the old email to the new if you edit so they can still receive email from old address at the new so it may be the best choice (I am not 100% sure on this), OR 2- create new email addresses with the new domain