Pep Guardiola ended his Bayern Munich reign with German Cup trophy
Dortmund's top scorer Pierre-Emerick Aubameyang sidefooted over a great chance towards the end of normal time.
There were no goals either in extra-time, although Bayern striker Robert Lewandowski was only denied by a great Eric Durm block.
Dortmund failed with their second and third kicks, as Manuel Neuer saved from Sven Bender and Sokratis Papastathopoulos missed.
Bayern centre-back Josh Kimmich struck his team's third kick straight at Roman Burki straight after Papastathopoulos had driven wide, but Thomas Muller and Costa scored for Guardiola's side.
It means that the manager, who is leaving to take charge at Manchester City, completed his three-year reign with a second German league and cup double, having secured the Bundesliga title in April.
Borussia Dortmund have lost three German Cup finals in a row; to Bayern in 2014 and 2016, and to Wolfsburg in 2015
There was disappointment for Dortmund captain Mats Hummels, making his final appearance for the club before joining Bayern.
The Germany centre-back, who has been criticised heavily by Dortmund fans since the move was announced earlier this month, was forced off with cramp in the second half.
An attritional contest between the Bundesliga's top two clubs offered plenty of edge but few clear chances.
Franck Ribery was perhaps fortunate to escape with only a booking in the first half, retaliating to a foul on him by barging into Gonzalo Castro and then poking the Dortmund midfielder in the face; both men were booked.
Dortmund, who finished runners-up to Guardiola's team in this season's Bundesliga, expended plenty of energy in trying to soak up Bayern's pressure.
They visibly tired as the match wore on, with full-back Marcel Schmelzer limping off moments before Hummels' departure, and Aubameyang also pulling up with cramp in extra-time, although the striker was able to complete the game.
Defeat means that Dortmund end Thomas Tuchel's first season in charge without a trophy, having lost in the German cup final for a third successive season.