Mackay, who signed for Hibs last month in a six-figure deal from Inverness Caldedonian Thistle, played the whole friendly at Dumbarton's C&G Stadium and while he was involved in two of Scotland’s goals, he also missed three good chances against the Northern Irish.
Early on in the match, Mackay robbed goalkeeper Dermott Mee of the ball outside of the penalty box, but the 20-year-old could not take advantage of an empty net.
Mackay was then denied one-on-one with Mee after the stopper’s poor clearance fell right at the former Inverness starlet’s feet, but Mee recovered well to save.
Scotland U-21s did take the lead through Tom Clayton on 23 minutes, who fired home after Mackay’s corner broke loose.
Ben Wylie equalised for Northern Ireland six minutes later, but Ben Williamson had Scotland back in front before half time with a lovely strike from 25 yards out.
Mackay ought to have scored at the start of the second half, but his lob over Mee cleared the crossbar after another moment of slapstick by the Northern Ireland keeper.
The visitors then equalised through Ryan Waide before, on 78 minutes, Mackay surged into the Northern Ireland box and won a penalty after Dylan Boyle tripped him. Glenn Middleton converted from the spot to seal the win.
Mackay will now get some time off before joining up with his new Hibs team-mates at the end of the month for pre-season.