Why am I writing this? What gives me the authority to say anything on stutters? Well, I'm writing it because I know several people with characters that stutter, and I used to have a moderate (and fairly life-interfering) stutter myself. I don't anymore except in rare circumstances, but I thought I could regurgitate my experience and what little research I've done into the topic to give anyone interested some kind of boost. I'm by no means an expert and if anyone else has something to chime in with, by all means.
What Stuttering Is and Isn't
There are three parts of stuttering. Only one part is repeating a sound - there is also prolonging a sound, and what's called blocks, or involuntary silences and pauses. Speaking frankly, the blocks really suck, but we'll get to that later. You can also have repetition of entire words or phrases, not just a sound.
Stuttering comes in many different severities. Some people only stutter very rarely, and some people can barely speak because they can't get the words out. There's a broad spectrum and you should decide where your character falls on it.
It's also important to note that no one knows precisely what causes stuttering to start with. It's true that being self-conscious, anxious, or afraid, makes the stutter worse, but what causes one person to stutter over another? This isn't exactly known. It's never been proven to have a correlation to either anxiety or intelligence, whether low or high.
And finally for this section, stuttering gets worse and better depending on the situation. You may have heard that some people don't stutter when they're singing at all - that can be true, and it can also be true that they get worse or better on the phone. As a real life example of this, Nicholas Brendon, who played Xander on Buffy: the Vampire Slayer, took up acting to help his stutter. If you've ever seen the show, you know that his character doesn't have a problem with it.
The Anxiety Loop
So I've cleared up that anxiety doesn't seem to cause stuttering, but it is definitely a part of it. What happens is that someone, somehow, gets a stutter. They're in a conversation. They have trouble saying something, i.e. the stutter manifests. People inevitably will comment on this.
Telling someone with a stutter to slow down, take their time, start from the beginning, say it another way, anything like this makes the problem worse way more often than not. Calling attention to it makes the stutterer more self-conscious than they already were about themselves, and therefore it makes them stutter more in a positive feedback loop. Even if someone doesn't say anything, the stutterer might have the expectation that they're thinking it, however accurate or inaccurate this is, and cause their own problem to worsen.
If they're nervous, anxious, stressed, have low self-esteem, anything like that, in a particular situation, they're likely to have a worse stutter as well. Eventually their self-image becomes crystallized with the idea that they have a stutter and they stop trying to fix it, they just try to live with it and work around it.
I will add here that low self-esteem and whatnot are not 100% present. For my part, there were many times when I couldn't get something out and I wasn't self-conscious in the least. I became frustrated over it and that did make it worse, but I didn't start there - I just had a kind of jittery, nervous personality that lent to the problem.
The Specifics
So this is all great, but how do you actually write the specifics of a stutter? I'd strongly suggest picking a few sounds for them to most commonly trip on (for me, it was Ds), think on possible coping strategies they might have, and decide what situations make it worse or better for them. This is a lot of work and honestly you don't need to do this to the death in my opinion, but I'll lay it out in case you want to.
First let's cover blocks in greater detail. A block was previously described as an involuntary silence. Well, it's really honestly involuntary. In all likelihood if your character is stuttering, they're pausing, too, and potentially all over the place. So consider taking your dialogue from: "D-Did you do the homework?" to, "...D-Did you" or even, perhaps most accurately but cumbersome in writing, "D--... Did you". A lot of trouble in writing blocks is that they look funny in text. All I can say is make creative use of your punctuation and decide for yourself how much you want to feature them. But in all honesty, very little is more aggravating than standing there, knowing what you want to say, and being physically unable to get it out.
I mentioned coping strategies. So someone is stuttering and someone points it out, they get self-conscious about it, it becomes worse. They're not unaware of this. They know they have a stutter and they know they should be trying to fix it, but they don't know how. What happens is they end up finding ways to avoid stuttering altogether (including avoiding people, full stop). For example, I mentioned earlier that I had particular trouble with Ds. So I would never say, "Did you do the homework?" I would always start anything that was "did you" with instead, "have you done". I also learned to wait several seconds and breathe before starting to say anything. There's a lot of tricks like this that really rely on what their specific stuttering habits are.
Conclusion
In the end, my greatest advice is to pick the details of their stutter, write it down somewhere, and just stick with that for the rest of forever. There is the caveat that over time a stutter will mysteriously disappear, particularly in children; I think something like 70% of children's stutters disappear within two years. If it lasts longer than that, they're much more likely to have it for life or at least much longer. I would advise, too, that less is more and when in doubt, have them stutter less. Save it for when it has more of an impact.
Okay I think that was enough... tl;dr. Don't worry TOO much about this, in conclusion; I just wanted to put this out there in case anyone wanted to know, as I've seen a few requests.