You will need a Hex Editor, Notepad and to enable your console.
1. Enable your console:
1a) Open your steam
1b) Go to Games-> View Games Library
1c) Right click DotA 2, then click properties
1d) Click on set launch options
1e) Type in -console and click OK
1f) Start DotA 2, and press `.
2. Download any Hex Editor. I recommend HxD Hex Editor:
http://mh-nexus.de/en/downloads.php?product=HxD
3. Install the program and run it.
4. Go to File, then New
5. You should see two columns. The left side will be the hex codes:
The right side will be where your name will appear.
6. Click on the right column and type the following:
7. Now you can start with colouring your name. All colouring will be done in the left column. Select the empty space after the last 2-digits.
8. Now that you have highlighted it, type in a 2-digit number that corresponds to the colour that you want. Below are the colours and their corresponding colour codes:

For this example, I am going to get something like this:
Testname
I will first type the colour code for red, which is 12 on the left column:

Some symbol or a dot will appear on the right column.
9. Now, it is time to type the words you want of the colour. For this example, I want the letters "Te" to be red, so I will select the right column, then I will type Te.
10. Now I want the letters "st" to be the colour lime green. So I will select the left column, and type the colour code 0C:

I will then select the right column, and type the letters "st".
11. Repeat the same thing for other colours. For this example, I will want the letters "name" to be pink, which has the colour code 11. The end result will be this:
12. After you are done, select the right column and type "
13. Now save the file as any file name.
14. Exit HxD editor, and open the file that you just save. Your system should prompt you on what program you want to use to open the file:

Select Notepad.
15. When you opened the file, this is what you will see:

Highlight the entire line and copy it.
16. Go to DotA 2, and enter into any game. This method will not work if you just typed it without spectating or playing any game.
17. Enable your console (By pressing `), then paste the line that you just copied. Press enter after that.

It is ok if the symbols disappeared.
18. Go back to the game, and you will be able to see your result:
Enjoy your coloured name in DotA 2!
NOTE: You have to do this for every game you spectate or play. It will disappear when you start a new game or spectate a new game.
NOTE 2: This will also work with typing in chat. Copy the weird symbol as shown in notepad that corresponds to the colour that you want, and paste it before every line you want of that colour.
Credits go to xpforever for the Hex editor and Wolbachia for providing the idea