The key to any sample letter for a character reference whether it goes to a judge or not is to make it look professional. The sample letter from Microsoft.com will show you where to put your name and contract information, as well as other contact information if necessary.
You should address the judge if you know their name otherwise use the typical salutation of "to whom it may concern.” Below this section consider rewriting what the template had using some of the same words, but for the situation you are writing the letter for. For example, if you are writing the character reference because the person is trying to get custody of their child consider what makes a good parent and whether this person has those qualities. If you do not think you can write the letter honestly you should decline being a character reference.
Once you have a solid paragraph end with a positive statement such as this person will succeed in any endeavour or I truly believe this individual etc. The point is you need to show your support in one summation sentence based on what you provided in the letter.
At the end put sincerely, leave a space and then type your name. Print the document off and sign it. If you do not use office there are other character reference templates you can find such as through Google Images.