Thinking out loud, stop me if I’ve stepped off a cliff:
The HAT’s GND is almost certainly USB DC V-, while your sensor’s ground ref is probably its power V-. So the safest alternative seems to be what I mentioned before: Power both sensor and Pi from the same source, stepping down 12V DC to 5V for the Pi via a buck converter or something. That way, both devices should have the same signal ref, and everyone’s happy.
If that’s not possible, then I think you’d have to run the sensor output through an opto-isolator or something, so that the correct signal voltage is seen on the HAT even though there’s no common signal ground.