Good questions, since we are usually trying to take stains out of grout.
First you should be aware that you can purchase coloured grout. The renovation stores will have three or four base tones to choose from, not too exciting. Go to a speciality tile store and you will discover a wide variety of very interesting colours.
Coloring epoxy grout
To stain existing grout you first have to find out if it is porous or not. Epoxy grout will not let anything in, that is why it is so good in that it is in fact stain resistant. They do make a paint like cream made for going over epoxy grout. You clean it off well first, then paint on the colorant. Keep the extra around for touch-ups, because this is only skin deep.
Staining regular grout
If you have regular grout but it has fresh silicone sealer on it and water beads up on it, no stain will go in, and nothing will stick either. Here you will have to either wait, or scrape the old grout out and replace it with tinted grout. But if it will absorb water, you could stain it with anything that stains, from regular wood stains, to tea bags or beet juice. Let it dry thoroughly and then seal the stain in with the regular silicone sealer.
Control the stain
Be sure to wipe anything, from the cream colorants, to any stain off of the tile itself immediately, in fact masking the tile would be smart. Some tiles may shed the stain, others may pick up the colour.