WASHINGTON — For the clusters of onlookers, besuited power players and three former presidents who had all traveled to Washington National Cathedral, the muggy day was a historic opportunity to memorialize the life of Senator John McCain, who was remembered as a deeply patriotic war hero, a former Republican presidential candidate and a scrappy, humanly flawed, ultimately idealistic lawmaker.

For President Trump, it was Saturday.

In the many discussions about how to mark his life that Mr. McCain had with his staff and family before he died, he had made clear he did not want Mr. Trump to participate in anything they planned. So as Mr. McCain was eulogized in the presence of much of the American political establishment, Mr. Trump, pointedly uninvited, engaged in what by now is a familiar weekend routine. He sent a series of angry tweets aimed at some political adversaries, then left the White House to play a round of golf at his resort in Virginia.

“This is the scandal here — a police state,” the president wrote, quoting a conservative commentator about a purported conspiracy to spy on Mr. Trump, as Mr. McCain’s coffin was carried into the cathedral.

He dredged up the investigation into his campaign’s ties to Russia and complained about it. In a series of tweets, he argued that “the DOJ and FBI are completely out to lunch.”