A local politician in northern Germany who posted a picture of a sex doll with a St Pauli T-shirt and a noose around its neck has stepped down following a wave of criticism.