The lawsuit challenging the addition of the question was filed by New York, other states, localities and advocacy groups. They said that asking the question was a calculated effort by the administration to discriminate against immigrants.

Asking about citizenship would “fatally undermine” the accuracy of the census, they said, because both legal and unauthorized immigrants might refuse to fill out the form. That could reduce Democratic representation when state and congressional districts are drawn in 2021, and affect the distribution of hundreds of billions of dollars in federal spending.

The advocacy groups said Mr. Ross’s testimony was needed in light of his “shifting and inaccurate explanations” for the change. He initially said that he had acted in response to a December 2017 request from the Justice Department and that he had not consulted with the White House.

Later, Mr. Ross acknowledged that he had been exploring the idea long before receiving a letter from the Justice Department and that he had discussed the issue with Stephen K. Bannon, then President Trump’s chief strategist, in spring 2017.

Those discrepancies “have placed the credibility of Secretary Ross squarely at issue,” Judge Jesse M. Furman of the Federal District Court in Manhattan wrote in ordering the deposition to go forward.