Justices issue injunction against legislation which removes requirement for caretaker mayors to sit out an election period before running for the office they were appointed to