We ought to hang people for parking on double yellow lines. Many years ago, it was established that the typical murderer was not deterred by the death penalty; often the more 'balanced' ones committed suicide , a particular feature of domestic murders, and the rest didn't give it a thought.
However, the generally law abiding, the mass of the population, would deterred by draconian punishments for their own offences. A really severe penalty for the kind of offence that they might be tempted to commit would deter them. Hence the correct, but theoretical, proposition that the death penalty would work to stop illegal parking! (It would work to stop noisy neighbours, too)
By the way, the admiral whose execution gave rise to 'pour encourager les autres' was an unlucky man. The tribunal that found him guilty of dereliction of duty recommended mercy. But Byng was shot anyway, to encourage the others.