Wednesday started off positively as Marco Matias fed Ross Wallace through the centre early on, but the former Burnley midfielder was unable to finish.
The Owls then took the lead 12 minutes in after Atdhe Nuhiu met Wallace's corner to head beyond Luke Daniels.
Scunthorpe equalised just two minutes later as Irish striker Madden finished from close range.
Nuhiu was involved again as Wednesday took the lead for a second time 10 minutes later, with the Austrian's pass allowing Matias to tap home.
The home side were quick to react with their second goal as Madden volleyed beyond Keiran Westwood to level things up at the half-time break.
Scunthorpe continued to threaten early in the second with defender Scott Laird, whose low drive stung the fingertips of Westwood.
Madden then came close to completing a hat-trick for Scunthorpe, but Wednesday defender Liam Palmer was on hand to make a goal-line clearance.
Mark Robins's side finally took the lead for the first time in the game with just over 20 minutes to go until the final whistle. Dutch striker Kevin van Veen forced his way into the box before placing the ball beyond the left side of Westwood to make it 3-2.
Sheffield Wednesday substitute Caolan Lavery looked to get his side back on equal terms minutes later but could only see his shot saved.
Scunthorpe then had the last laugh as 18-year-old striker Kyle Wootton sealed a 4-2 victory with a guided header just seconds before the final whistle.