First things first--plot twists have to be planned if you really want to pull them off. It’s hard to add a good or even passible plot twist after you’ve already started planning and writing your story. If you think you need a twist because what you’re writing doesn’t seem able to stand on it’s own or isn’t interesting enough without a twist, adding a one in isn’t going to help much. You’ve got to plan the twist from the beginning so that it make sense and, while it still surprises the reader, they won’t feel like you cheated or tried to pull one over on them.
Once you know why your story should have a plot twist and what the twist is, exactly, there are a few different ways to keep it a surprise to your readers until the big reveal. One common methods is a red herring, or leading your readers to suspect one thing is going to happen and then surprising them with something else instead. This is common in mysteries when the detectives suspect one person but it turns out to be someone else. The first suspect is the red herring. However, I don’t really like red herring because they can often feel like a cheap trick used just to fill time, and most smart people can spot them anyhow.
You can try letting your twist happen completely out of the blue, but you better have a damn good reason for it because readers don’t like this kind of trick very often unless it’s for a good reason. Try to avoid having a totally new character step in to save the day. I mean, unless that character was at least mentioned earlier or is going to become a big deal very soon after, I’d avoid this kind of thing. Also avoid convenient coincidences as much as possible. For readers to be convinced and emotionally invested in your story, everything that happens should be directly caused by a character's actions or choices.
My favorite type of plot twist is the one I should’ve seen coming but didn’t because I didn’t want it to happen. This would be a good guy trying out to be a bad guy, pretty much any type of betrayal, killing or harming a favorite character, or something shocking the reader just wouldn’t imagine you’d actually do. You can subtly elude to these types of twists, but as long as the audience doesn’t want it to happen, they’ll be surprised. The best plot twists are the ones the reader doesn't want to see coming.
The biggest thing to be careful of is to not back yourself into a corner or become predictable. If your characters always have more than one possible option, escape, suspect, etc., then your readers will always have to keep guessing and won’t know where you’re going to take them next. That’s good. If they can’t figure out what will happen next and want to find out, they’ll keep reading. But if you only leave room for one possible outcome, readers don’t have to guess what will happen next, and that’s boring.