Haller was subbed on just after halftime in the match, with Dortmund leading 3-0 in the fixture, played in the Spanish seaside town of Marbella.
The French-born Ivory Coast striker scored from the spot – his first goal in Dortmund colours – in the 81st minute after American winger Gio Reyna was brought down in the box.
Haller doubled his tally just five minutes later when he tapped in a cross from Julian Brandt, completing his hat-trick two minutes later when he side-footed in a corner.
❤️⚽️ Sébastien Haller got a hat-trick within 7 minutes against Basel in a friendly today! pic.twitter.com/SH9w3k9NV3— EuroFoot (@eurofootcom) January 13, 2023
Haller joined Dortmund in the summer of 2022 from Dutch club Ajax but was diagnosed with testicular cancer before making an appearance for the club.
Haller on Tuesday revealed he had gone through four rounds of chemotherapy and had undergone two operations but has now fully recovered.
Dortmund, who sit in sixth place in the Bundesliga table after 15 games, re-start their season at home against Augsburg on 22 January.