What a good question, I have wondered the same thing myself. My first thought is to do it on the fourth of july, in the evening.
My second thought is to call the coast guard and see what they say. Maybe if they know you are doing it then it wouldn't be such a bad thing to do, though that wouldn't let other boaters know what you were doing. Maybe after you set one off you can set off some colored fireworks at the same time to kind of let everyone know you were just fooling around and not actually in an emergency situation.