Interesting read, here.
https://www.nationallibertyalliance.org/countysheriff
The best way to deal with such a rogue sheriff is to allow the people to sue for damages when their policies cause irreparable harm.
Of course, that door swings both ways wrt “gun control” laws.