The D-backs were trailing 5-2 in the third when they erupted for five runs to grab control of the game.
After Ryan Roberts coaxed a bases-loaded walk from Zack Greinke (5-2) and Jason Kubel scored on Konrad Schmidt's groundout, McDonald yanked a pitch into the left-field corner that barely made it into the stands for a three-run shot.
Wade Miley (6-1) won his third straight start, yielding three runs (two earned) on eight hits in a six-inning performance.
Greinke was roughed up for seven runs on 10 hits in 2 1/3 innings for the Brewers.
Cody Ransom cracked a two-run double while Jonathan Lucroy added two hits and an RBI for Milwaukee.
Rosie O'Donnell unveils nearly 50-pound weight loss
Justin Bieber crashes Drake Bell's album release party