It’s against the law to flash your brights to inform an oncoming driver that he forgot to turn them off?
Probably not, but it does give an officer an excuse to pull you over to find out why you did that and give a warning, or write a ticket if he can.