Wouldn't it be quite exciting for chastity device keys to find their way into a prison or barracks for "safe keeping"? Quite appropriate too, thinking about it! I'd love the idea of my manhood being locked and the keys also on premises where other men are deprived of their freedom!
I know of a couple of pro Dom’s that have several subs locked 24/7 and when they have sessions they are kept in barracks/ cells. So very similar to your fantasy.
How about a prison where everyone is in chastity? Would be funny if judges could order it but I doubt society would benefit from criminals that can't get any sexual relief.