A pulsar in a binary with a compact object in the mass gap between neutron stars and black holes