It's possible to spray your tank with it running, but unless you do a perfect job of sealing off the tank, there is a chance of overspray getting into your tank. If you do attempt to spray, follow NewFishLINY's suggestion of thin coats; because a tank that gets sprayed while it's set up has gravity going against it (you might get runs if you're not careful).
A suggestion I would like to make if you're not 100% with spraying your tank and afraid that some overspray might make it into the water would be to use a detachable background. Purchase a thin sheet of acrylic from Home Depot and spraypaint a suitable background on that. Fasten it to the tank with velcro, two-sided tape, or such, and the results will appear almost as if you sprayed the tank.