Yes, drivers should be allowed to flash their headlights to warn of speed traps, because drivers have a right to free speech, even if that means that someone gets away with speeding. It might seem unfair to the police, but there is nothing good about shutting down free speech in the name of being able to distribute traffic tickets. The police will have to move somewhere else.
I live in the United States, which means that the question of whether or not drivers can flash their lights this way can be answered by three little words: First Amendment, baby! Police don't have a right to keep their public operations secret by forbidding the public from talking about them.
People are allowed to flash their headlights on a daily basis regardless of where they are, so why are they suddenly not allowed to do so in this one area? If cops are going to pick arbitrary places where people are pulled over then others should be able to warn them.
I do not believe speed traps should be allowed, but as long as law enforcement uses them, I believe motorists should be allowed to flash their headlights to warn cars going towards them. I believe this is a fair trade off to the manipulative tactics used by law enforcement. I was happy to hear the state of Missouri upheld this right recently.
There is nothing wrong with another driver warning someone else that there is a possible speed trap coming ahead. It helps them know that they need to slow down, which is what they should be doing anyways, and stops them from getting pulled over and facing a fine. Nobody likes to deal with police, especially over something like speeding, so helping someone out is not a problem at all.