Question for DMs: it's pretty much become the house rule for the DnD group I'm currently a player in to beat down locked doors instead of finding the key or looking for another way around.
This is a great question. So let's start with something very simple...
Why is the door locked? Who or what is on the other side? Doors should usually be open, if you want the door to require a key you need to answer those questions and make their answers matter.
In addition to that think about why hacking a door down might be a bad decision, then put those bad decisions into the dungeon. Time limits, wondering monsters hearing the noise, bad guys getting ready, bad guys escaping, hostages being killed, and so much more.
Here are a few examples.
The Locked Guard Barracks -
Inside of this room is a bunch of drunken mercenaries hired by the evil guy. They lock the door to keep out wondering monsters and so they can drink without the evil guy getting on their case. If you take your time trying to knock down the door, they get ready for battle. Flipping over tables for cover and readying to take attacks. If you unlock the door, you get the surprise action and can talk out of the fight.
The Locked Hatch -
On the floor is a sturdy wooden hatch that leads into a dark room that smells of rancid trash. Hiding in the trash is an Otyugh and banging on the door usually means feeding time for him. So he moves close enough to door to grab the first person it sees, dragging them into the darkness. If the door is opened quickly, the Otyugh is in the open moving towers the door.
The Goblin Den -
An old ratty door. Easy to hack through, but goblins are skittish little creatures. They run into tiny tunnels that connect to other rooms and warn the other goblins about intruders. That was their favorite door after all. Now you will pay.
The Studious Wizard -
Tired from studying all night, if the party keeps up that racket they are going to get a fire ball right in the face.
The Wondering Worm -
Hacking and banging draws the attention of a Purple Worm under ground. Maybe he misses on the first bite, but he will be much more accurate the next time.
The Door of Golem Disintegration Trap -
A mage under attack by his own Golems, enchanted this door to protect himself. Only living things can safely use this door. If any non-living matter touches the door it turns to dust. Including weapons, gauntlets, and golems. Be nice and give magic items a saving throw.
Slowly Approaching Doom -
A Fog that drains hit points slowly creeps closer. There are 3 doors to get through and no one is searching for the key.