Not exactly a hypothetical question with respect to sexual orientation. Since I was a young man (and well before that), cisgender gay man were required in many legal circumstances to disclose their sexual orientation on pain of legal consequences.
I lied when I joined the US military in the early 1980s, claiming falsely that I was not gay. That could have landed me in prison. In fact, after I failed a routine FBI security-clearance polygraph, I worried intensely about those legal consequences. As a result, I left the Air Force.
Also, cisgender gay men have, for most of my adult life, been required to disclose our sexual orientation when donating blood. You could make an argument that such was practically necessary at one time due to HIV concerns, but other less intrusive and equally effective questions could have been asked instead.
So let's not pretend that intrusive questions about sexual orientation don't actually happen.