If your variable is observed there is no sampling going on so you don’t have to worry about it.
Otherwise you would need to implement your own step sampler that never proposes dumb values. You could probably subclass whatever step sampler is being used and tweak the proposed values (just make sure to keep detailed balance).
Otherwise there was a draft sometime ago to allow discrete variable transforms, so the samplers don’t need to know about these things: Implement transforms for discrete variables by ricardoV94 · Pull Request #6102 · pymc-devs/pymc · GitHub
If you think that functionality would be useful for you, feel free to chime in on the draft