"You can change your palette mid-game so long as the new palette is four colours. You cannot change your colours mid-scan-line or any other sneaky trickery. If you have more than four colours on the screen at any one time it is not obeying the rules."
If you want to know more about the four colours rule a good place to look is the GBJam discord where there is an extended explantion on it.