Is there a way I can lock my door in vanilla Minecraft? I have tried naming a tripwire hook key, but it didn't work youtube told me to do that.
There are two very simple ways I know of to "lock a door". Of course, these both assume that the gamemode is adventure and other players cannot grief it down. Otherwise, you would need a special plugin/mod to stop this.
Idea 1: Use an iron door. (Like what was mentioned in the comments.) When the lever is powering it from the inside, it is always open, when the person on the inside turns off the lever, the door is closed and cannot be opened from the outside.
Idea 2 If you want a wooden door, you can use the painting trick. This is where you place a painting over the door. It not only hides the door, but also essentially locks it. If the door is open, one can pass right through the painting into the room. Once inside the room, they can close the door behind them, without griefing the painting, the person on the outside cannot pass through or open the door.
Alternatively, you could simply hide the entrance. This may be your best option for factions/pvp/raid servers where players can grief and may be trying to get into your bases and buildings.