The White House refused to rule out Wednesday whether President Obama might grant a pardon to Hillary Clinton to spare her from President-elect Donald Trump prosecuting her after he takes office.

White House press secretary Josh Earnest said Mr. Obama is hopeful that Mr. Trump will follow long-standing tradition of not punishing political opponents through the criminal-justice system. He said all clemency actions go through a formal process, and that will remain in place until the end of Mr. Obama’s presidency in January.

“The president has offered clemency to a substantial number of Americans who were previously serving time in federal prisons,” Mr. Earnest said. “We didn’t talk in advance about those decisions.”

He said Mrs. Clinton “has worked very hard over a long period of time, and we owe her a major debt for her service to our country.”

Mr. Earnest also said the president was encouraged by Mr. Trump’s “tone” in his victory speech early Wednesday, suggesting that the White House believes it’s an indication that Mr. Trump wouldn’t call for a prosecution of her when he takes office.