WASHINGTON—President Trump was booed during his first visit to a professional baseball stadium as commander in chief, a chilly reception from World Series fans just a few miles from the White House.

A “lock him up” chant broke out in the stadium after Mr. Trump, seated in a suite with his wife and several Republican congressmen, appeared on the jumbotron following the third inning. The president’s supporters often chant “lock her up” at his campaign rallies, a reference to their displeasure with Hillary Clinton, the 2016 Democratic...