Could be the sensor, but not likely. It could be the tone ring in the rear end... if you haven't changed the fluid in a while, I'd start there. Or, it could be the PSOM, which is a computer module built into the speedometer head. If it's the PSOM, you have to replace it. While that's not a big deal... the PSOM stores the truck's mileage, so whatever mileage the donor rig had will now show on your truck. I do believe there is a place that rebuilds them, but when the PSOM crapped out on me in my old 95 gasser it was cheaper to buy a new cluster. And... I got lucky and found one that was within a few hundred miles of actual for the truck.
Another thing to note... if you end up buying a used cluster for the PSOM, if it's not from the same year truck you'll have to disassemble the cluster and swap the good speedometer/PSOM into your cluster. There are minor differences in wiring (IIRC for a PSD 94-95 are the same and 96-97 are the same) and if you drop in a cluster from a different year truck, you'll end up with random lights on all the time and some that don't work.