To Mega Evolve a Pokemon in battle, you must have the appropriate Mega Stone for that Pokemon (Or Dragon ascent, in Rayquaza's case) and the Mega Bracelet, which you get from Steven after catching Latios/Latias on Southern Island.
Once you enter the battle, send out the Pokemon you want to Mega Evolve. While selecting the attack you want to use, press the button at the bottom of the screen to Mega Evolve that Pokemon.
You will not be able to Mega Evolve a Pokemon if you don't have to Mega Bracelet, your Pokemon is not holding the Mega Stone that allows them to Mega Evolve (Or if Rayquaza does not know Dragon Ascent), or if you have already Mega Evolved a Pokemon in that battle.
Hope this helps!
Source