france : Yes, unless
- you are outside a city
- it is daytime
- you can convince the cop or the judge that doing so is a "necessary warning for other road users". Not my specialty, but barring extraordinary circumstances, I expect that defense to fail.
Code de la Route, articles R416-1 and R416-2:
Hors agglomération, l'usage des avertisseurs sonores n'est autorisé que pour donner les avertissements nécessaires aux autres usagers de la route.
En agglomération, l'usage de l'avertisseur sonore n'est autorisé qu'en cas de danger immédiat.
(...)
De nuit, les avertissements doivent être donnés par l'allumage intermittent soit des feux de croisement, soit des feux de route, les signaux sonores ne devant être utilisés qu'en cas d'absolue nécessité.
Outside city limits, klaxon may be used solely to give necessary warning to other road users. [For instance, when driving around a mountainous road, you are supposed to honk when approaching a curve without visibility, so as to warn drivers coming ahead.]
Within city limits, klaxon may be used only in case of immediate danger.
(...)
At night, signals must be given by flashing headlights, klaxons must only be used in case of absolute necessity.
Failing to respect those rules is a second-class contravention (currently set at €35). Technically, those apply to any vehicle, including bikes (even if bike klaxons are much less noisy than car klaxons).
While in theory it is irrelevant whether there is a cop in the car in front, behind, or sideways of you... I imagine less than 0.1% of wrong klaxon uses are penalized, and all of those occur when a cop was on-site.