Know something about what the possible sentences are. The less discretion the court has in the range of sentences, the less you should talk. If a sentence carries anywhere from a fine to years of incarceration, you want to put a lot more into it that if the possible sentence is only a small fine. Don't waste time arguing for what you can't get, for example if the offense carries a mandatory jail sentence, there is no point arguing for probation.
If probation is an option, note things in your life that show stability. If you have a good job, or have been at your job a long time, that shows you have something to lose if you don't follow the rules of probation. Same applies if you own a home or run a local business. If you have people who count on you or count on your income, note it. The judge should be made aware of how your sentence will impact other people, but don't expect that a judge will take it easy on you just because you have a family to look out for, the judge is likely to point out you were not thinking of your family when you committed your crime.
Do not blame anyone but yourself. Blaming is a failure to take responsibility for your actions (as far as the judge is concerned), and judges will hold it against you. No matter what the circumstances of the case, don't try to turn it around on someone else, particularly the victim. Even partial blame is bad: I've seen defendants criticize their attorney's work on the case, or talk about how they grew up in tough circumstances, or claim someone else got them started in a bad direction, etc., and it always ended up with a tough sentence. If you pleaded guilty or are not appealing a guilty verdict, take full responsibility for your own actions and the consequences of those actions. This includes anyone else you have speak at your sentencing or write a letter to the judge, such as parents, they should not take responsibility for your actions either; if they do, correct that with the judge and tell them it is not your parent's responsibility, it is yours.
Don't make yourself out to be better than you are. It's human nature to see yourself in a better light than others may see you, but critically think about yourself before you try to describe yourself to a judge, particularly with respect to your criminal record. One example I have seen several times is someone saying they don't drink often, but then the judge points out that they have multiple alcohol related convictions, or they say they aren't violent, but they have previous convictions for assault.
Don't argue with the judge. Judges will often give a defendant a lecture at sentencing, just put up with it. A lecture is better than incarceration. If a judge is wrong about an important fact, you might politely correct them; for example if they said you have three prior convictions when you have one, it could effect the sentence so you should point that error out to the judge. If you have an attorney, point it out to your attorney and let them handle it.
Don't challenge the case or the evidence. This goes along with blame. If you are appealing a verdict, save it for the appeal, but arguing the case or the evidence was insufficient, or the case would have gone better if you had won a pretrial motion, etc. is just going to be seen as a failure to take responsibility. This is especially true when you pleaded guilty, and in that situation there is a danger the judge could reject your guilty plea and reset your case for trial. If you don't feel that you can sincerely take responsibility in a case, say nothing about the case!
Do not apologize to the court. This really pisses some judges off. They are just there doing their job and they are not victimized by your actions, even if you took a weak case to trial. If you are going to apologize, only do it to people who are actually victimized by your conduct. But if your apology is not sincere, you are only going to make it worse.
Think about what you want to say, but don't write out a speech. Reading off a prepared statement is at best ineffective and at worse insincere. Prepared statements sound forced and artificial, and particularly reading off a piece of paper shows a lack of sincerity. Your attorney might have a prepared statement, but that is because they are speaking for you and not themselves.
For more tips, see Part 3.