Bad sensor or bad gauge?

It would stay at zero until I grounded the wire then it would jump to max.

Dumb question here but what is the correct way to wire the sender? It’s similar to this one but it has a black insulator instead of white.

View attachment 1716143509

View attachment 1716143510
Most sender units just have one wire that goes directly to the gauge.
Your test of grounding that wire generally means the gauge is working like it should.

Note that the body of that sender must be grounded for it to function, so products like teflon tape are a no no.