WASHINGTON — For years, President Trump has used Twitter as his go-to public relations weapon, mounting a barrage of attacks on celebrities and then political rivals even after advisers warned he could be creating legal problems for himself.

Those concerns now turn out to be well founded. The special counsel, Robert S. Mueller III, is scrutinizing tweets and negative statements from the president about Attorney General Jeff Sessions and the former F.B.I. director James B. Comey, according to three people briefed on the matter.

Several of the remarks came as Mr. Trump was also privately pressuring the men — both key witnesses in the inquiry — about the investigation, and Mr. Mueller is examining whether the actions add up to attempts to obstruct the investigation by both intimidating witnesses and pressuring senior law enforcement officials to tamp down the inquiry.

Mr. Mueller wants to question the president about the tweets. His interest in them is the latest addition to a range of presidential actions he is investigating as a possible obstruction case: private interactions with Mr. Comey, Mr. Sessions and other senior administration officials about the Russia inquiry; misleading White House statements; public attacks; and possible pardon offers to potential witnesses.