After Khaled Narey gave a lively Hamburg side the lead, the German champion hit back with two first-half goals from Wagner and two more after the break from substitute Muller to make sure of victory ahead of Sunday's (AEST) DFB-Pokal clash against SV Drochtersen/Assel.
Bayern, on the back of its 5-0 thrashing of Eintracht Frankfurt in the DFL-Supercup, lined up with Renato Sanches and Leon Goretzka in midfield, while Ivan Mihaljevic, Maxime Awoudja and Derrick Kohn started in a youthful defence.
Hamburg began the match at a frenetic pace and deservedly took the lead after 24 minutes when Lewis Holtby expertly controlled a loose ball in the Bayern box and squared to Narey, who slotted it beneath Manuel Neuer and into the net from close range.
Bayern drew level after Kingsley Coman was brought down on his way into the box on 30 minutes and Wagner dispatched the subsequent penalty low into the bottom left corner.
Wagner put Bayern ahead 10 minutes later, deftly flicking Goretzka's cross into the far corner with the outside of his right foot from a near-post position on the edge of the six-yard box.
Bayern coach Niko Kovac sent on Franck Ribery, Muller and Joshua Kimmich for the second half, and Coman went close to making it three after Goretzka played him in with a back-heeled cross.
Two of Kovac's substitutes combined to good effect after 72 minutes when Maximilian Franzke's low cross found the toes of Muller, who poked the ball into the net at the near post from point-blank range.
With five minutes left on the clock, Ribery combined with Kimmich down the left flank to tee up Muller for his second, which he drilled low into the bottom left corner from the edge of the box to make the final score more emphatic.