I have thought a lot about this topic. I am a married woman with a kid who had attended the big professional conference while 7 1/2 months pregnant. Most of my interviewers knew this information about me, so was often asked these questions on the job market. [1] I also mistakenly revealed the information a couple of times because I wanted to know about workplace culture. In the end, I got 0% of the jobs where the department knew I had a kid and 100% where they didn't. (Not statistically significant because of low sample size, but still...) Ever since that experience, I have paid special attention to articles on this topic.
I would abide by a few principles:
1) Provide as little information as possible. Anything you reveal may be held against you. If at all possible, provide a deflective, non-answer answer (including a joke). Frankly, any member of the search committee who is aware of the laws/cares about the discrimination will probably be grateful to you for avoiding this complication to the hiring process. Finally, even if you have a "good answer" like "my spouse would be happy to move," the committee may still decide not to believe you and penalize you for a two-body problem.[2]
2) Be collegial. A great deal of weight is placed on collegiality once you have made it to the stage of a flyout. This is why you should not just say "That's illegal." or respond in a way that might be confrontational (especially if you are a woman or person of color). In my case, I found that people who asked these illegal questions were using them as a lead in to sell you on aspects of the university such as great child care, fun couples activities in town, etc. When the asker (possibly incorrectly) thinks they are helping you, they take umbrage at a confrontational response.
3) If the information is already out there, give them the answer they want to hear. First, assume anything that they can Google is "out there." This includes wedding announcements, gift registries for babies, etc. After you account for the information that is part of the "public record", I think you are under no obligation to be actually honest about details. You should spin your situation to your heart's desire. They should not be using this information, so it should not matter, right?
4) Pivot back to job-relevant topics as fast as possible. Any time you spend discussing personal matters like this could probably be better spent positioning yourself as the most qualified applicant who would be the biggest asset to the department. So move back to these topics as fast as possible.
Some examples:
"Do you have children?" "Some days I feel I have 60 children! I can't tell if my undergrads are 19 are 9 most days. I often find that they don't listen well to directions... [here is one way I have handled that in my teaching]"
"How is your new baby sleeping through the night?" is "Great! They are such a good sleeper and I am back to full-time productive research!" (HA!)
"Are you married? What would your spouse do if you moved here? The university career services office is happy to help with spousal relocation." "It is great that the university is able to offer that type of support for new faculty. Are the students in the department also able to take advantage of career services? What are the placement rates like for new graduates from the department?"
[1] It was clearly something that the committees discussed about me. I had a prep call with a faculty member in advance of my first flyout. The conversation started with the person asking me what my daughter was going to be for Halloween. I had never met her and she did totally different work so did not attend the professional conference where I had been pregnant.
[2] Important study related to this topic (paywalled): journals.sagepub.com/doi/abs/10.1177/0003122417739294 This finds that hiring committees often use information about marital status to make problematic assumptions about female candidates and illegally use that info in their decision making. The examples (the researcher was allowed to sit in on real hiring meetings at an R1 university) were incredibly egregious, including not offering the job to a top candidate because, even though she insisted her husband was happy to move, they didn't believe her.