Yes, it could be the lock sensor. These have a fairly hight rate of failure. They're a ball bearing detent arrangement with a push to make circuit. The actuator arm pushed the ball and closes the circuit making the light go solid. It doesn't mean the locker isn't engaged.
You really need to establish whether the rear is physically locked or unlocked. That's the starting point. The teeth on the dog clutch are really coarse on the rear so to save time, effort and any doubt, I'd lift a wheel off the ground, engage the locker and turn the wheel. Yes you can drive in circles and back up going lock to lock, but honestly, just jack a wheel up.
If it locks then it's the detent switch. If it won't lock after spinning the wheel, it MIGHT be the motor or quite often, the actuator rod can bind due to the motor not being quite mounted centrally. I'd loosen the 4 bolts on the housing very slightly then try again. A couple of soft taps might help.
It's possible but RARE that it's an electrical fault. SO try the easy things first.