I actually tried it for myself. Turns out Rayquaza Mega Evolves when the audience gets maxed out, performs, then stays Mega for the rest of the contest like any other Mega Evolving Pokemon in the contest. While Groudon and Kyogre are already Primal when the contest begins, and stay Primal throughout the contest. However, they are normal whenever the screen says: "Congrats" and shows your Pokemon, if you win,