To change your legal name in your Microsoft profile, you will need to contact Microsoft support for assistance. Your legal name must match the name on the government-issued ID you'll present at your exam appointment. If you've already registered for an exam, changing it requires Microsoft support approval. You can reach out to support through the following link: Microsoft Support.
Make sure to provide them with the necessary details about your current name and the name you wish to change it to, as well as any relevant identification to verify your request.
References: