Yes, but taking more than the minimum maternity leave generally will require you to extend your time in residency to some degree.
It's not legal for us to ask this (or any other question about marital status, etc. I personally appreciate it when applicants volunteer such info, though--I want to know who they have as supports in their life. I only ask about S.O. if they've specifically divulged their status in personal statement, CV (lots of people put "spending time with my spouse/dogs/cats/kids" in that Other Activities field), or interview.
We (speaking for our program at least) don't see it as a negative, and potential for parenthood has never come up in evaluation discussions or ranking. That said--I know it's awkward if you're asked one of those "illegal" questions--generally applicants don't want to be perceived as non-forthcoming. If you don't want to respond, politely deflect the question, or change the subject. Usually it's just a poorly trained volunteer interviewer. If it's malignant, I'd imagine you be getting those vibes at other points as well.