The only ethical stance I've ever heard for torturing someone is the "ticking time bomb" scenario popularized during George W. Bush's administration. (I disagree with that ethical stance, but that's beside the point.)
In your scenario the bomb isn't ticking. Nor is there even a bomb-- only a breach of security with an undefined relationship to safety and needs of people who aren't in any immediate danger.
Read the Senate Report on Torture for an in-depth analysis of the problems with that ethical stance.
SBF didn't sexually assault anybody, but the rules exist for such reasons, and SBF breaking those rules surreptitiously doesn't make it okay. The first concern, I imagine, was "how the fuck did that happen?" which meant assessing the damage.
Should he have been thrown in solitary for 24 hours? Probably not, but should he have been isolated from his room and other prisoners for 24 hours? Probably, while they assessed what had happened and how.
If he had snuck contraband in (a smartphone), then that would have been, for example, a real safety issue, since smuggling in contraband doesn't end at cell phones, and the pathway doesn't change. Initially, it was not clear how it occurred.
That's all I'm saying. I know the slippery slope argument, and I agree with it, and I have previously read the Senate Report on Torture, and do not disagree.
I would prefer, of course, that it wasn’t solitary.