Since you’re asking us, I’ll make the assumption that you’ve already checked elsewhere and gotten the basics. If you haven’t, then, there’s decent primers here and here. With thanks to The Writing Cafe for compiling this list of general writing resources.
Stephen King’s On Writing scatters dialog advice through the book. It’s more holistic, and interested in talking about how to be better as a writer, but, if you haven’t read it, grab a copy.
If you’ve already done all that, and wanting more advanced advice, then I can offer some random thoughts:
When it comes to fight scenes, remember that talking is not a free action. (With thanks or ire directed at D&D and TV tropes for that phrase.) Everything your character says in a fight is time they could better spend recovering and preparing for the next strike. I know it’s a genre staple in anime and manga, but outside of a deliberate homage, it’s just going to be bad writing. Cut your combat dialog down as hard as you can. It needs to be information that really cannot wait, or at least that the characters think can’t wait.
I have a minor preference for hearing dialog over reading it. Which means when it comes to dialog sampling, I put a slight priority on watching TV series with good writers over extensive reading, but, I also go read some of what they’ve written, and this isn’t a free pass to just binge watch whatever you want and say, “no really, I’m learning to write.”
Don’t try to copy another writer’s dialog style. You’re not Joss Whedon, and actually nailing the idiosyncrasies of his dialog takes a lot of work. It’s not that you’ll never be able to mimic another writer’s dialog patterns, but it’s a really bad way to start because he’s breaking rules you shouldn’t. Also, I’m singling out Whedon because I see so many writers (both amateur and professional) try to ape him, usually with disastrous results.
Whedon’s schtick is the way he mutilates the English language. It’s part, “in ways science never thought possible,” part teenager with an undefined attention deficit disorder (I’m not throwing this out there as a pejorative, his work reads like of someone trying to sound like they have an amalgamation of ADD and ADHD). Obviously, it works for him, but he’s walking a very fine line between sharp dialog and sounding like grammar is a thing that happens to other people.
Obviously, I’m not just talking about Whedon, though. Chances are, wherever you’re going to look at good dialog, you’re going to see a writer that habitually breaks the rules. Be that something like Aaron Sorkin’s obsession with context misalignment and high tempo conversations that run headlong into walls, or Straczynski’s habit of dumping entire pages of exposition into his dialog.
Look at them, study what they do, but don’t try to copy their styles.
Collect and study idioms. This is one of the things to do when you’re listing to other people talk, or reading other writer’s work. Just keep a mental list of idioms. Make sure you know what it means, and where it’s used. No, it wouldn’t make sense for your SoCal teen to say, “that dog don’t hunt no more.”
Also, remember that idioms are language specific, and are consistently one of the hardest things for a non-native speaker to pick up. So, non-fluent character probably shouldn’t be breaking out complex idiomatic phrases.
The reason is fairly simple: while idioms might follow normal grammatical rules, the meaning is, completely, arbitrary. “That dog don’t hunt no more,” has nothing to do with hunting or dogs. “Butter them up” has… well, none of those words actually mean anything. And of course, your reflexes are too good for metaphors to go “over your head…” …or something.
The insidious thing about idioms is, you already have a huge library of them. They’re a byproduct of how we use language on a day to day basis. What you need to do is step back, filter them out, and make sure they’re appropriate for your character, especially when your character comes from a vastly different background. Then, listen for ones that you don’t know.
Also, please resist the urge to re-purpose an existing idiom into your non-modern setting. “Like a cop eating doughnuts” getting adapted into your high fantasy story is like what Garfield strips are to comedy. Just, don’t do it.
On a related note: keep track of dialect changes. America doesn’t have a completely unified dialect. Cambridge was doing studies and surveys on the subject a couple years ago, though most of the easily accessible information now is just raw data. This isn’t huge stuff, but just word choice between things like “soda” and “pop” will change depending on where in the country you, or your characters, were raised. This is easily one of the hardest things to get right because of how subtle it is.
Keep track of verbal crutches and tics. Using words like “like,” “literally,” or “actually,” as flavoring particles. It’s something a lot of real people do, but be careful to moderate your characters, so they don’t use them too much, and so their verbal tics don’t match your own.
Just because you know what your character is trying to say doesn’t mean your other characters will. I mentioned context misalignment with Sorkin, earlier, because it’s something he uses for laughs. But, your characters are separate individuals, while dialog is about them interacting, it doesn’t mean they’re approaching the world with the same perspective, even if they think they’re agreeing with one another.
Actually, while we’re on this subject, remember your characters are separate people, with different interests, motivations, and backgrounds. It may seem unrelated, but it is important to keep your individual characters in mind when writing their dialog.
Do not try to be “enigmatic” with your dialog. Dialog is there to convey information to the reader. Conveying information between characters is a happy accident that happens along the way. Having someone trying to be deliberately enigmatic without a very solid character justification is just asking for messy, obnoxious dialog.
Also, note that pissing characters off with enigmatic dialog can be conveying information to the reader, it’s just not what the person is saying that matters. Just, be very careful with it.
If your characters need to use some kind of verbal code, make sure you translate that for the reader.
Don’t break the fourth wall in dialog. It’s fragile enough, it doesn’t need you taking a sarcastic claw hammer to it.
That should give you some things to start with.