Just after goalkeeper Paulo Motta saved
Playing his 22nd international match, Chandler doubled the lead in the 58th minute. Dempsey, replaced as captain by Michael Bradley, converted the penalty kick in the 72nd minute after Castrillo fouled Bradley.
The U.S. opens the defense of its Gold Cup title on Tuesday.
If the Americans win the tournament, the championship of North and Central America and the Caribbean, they would qualify for the 2017 Confederations Cup.
Wearing stars and stripes numbers on players' backs on the Fourth of July weekend, the Americans improved to 15-0-6 in their last 21 matches against Guatemala, their longest unbeaten streak against any nation.
Dempsey was suspended for three games by Major League Soccer for a confrontation with a referee June 16 in Seattle's fourth-round loss to Portland in the U.S. Open Cup, when he grabbed a notebook from the official and tore it after a teammate was given a red card. He also was suspended from the Open Cup for at least two years.
Klinsmann announced this week that Bradley was replacing Dempsey as the U.S. captain for the Gold Cup "to take the heat off Clint."
Dempsey's goal was his 41st for the national team, 16 shy of Landon Donovan's career record.