There are various ways through which you can change your Xbox Gamertag. The following steps will show you how you can change your Xbox Gamertag using the Xbox app:
Open the Xbox app
Click your profile picture at the top left corner of the application after which you will see your Xbox profile information
Under your profile picture, click Customise
Click change Gamertag and enter your new one. Keep in mind that you can change your Gamertag for free only once.
If you have already used your free Gamertag change, you will have to go to the Change Gamertag Page on the official Microsoft website.
Here you can choose a new Gamertag for which you will have to pay $9.99 (costs may vary)
Besides using the Xbox app, you can change your Gamertag by going to the Microsoft website.