It is practically illegal because relying on the answer to the question in employment decisions is illegal, and if you ask it in an interview, and you are challenged, it is going to be very hard to convince a jury or judge that it did not factor into your decisions.
It's not so much an "illegal question" - it's asking about something that's illegal to take into consideration when making hiring decisions. So there's no legitimate reason to ask it and any answers can't be used.
Our HR was run by our General Counsel, so they tended to be pretty strict about the language they used, and they called it "illegal."
I think asking questions about sexuality and/or disability may fall into the same bucket.