Anyway, a transformer works with AC current. For such a small power, a simple DC/DC converter will do the trick. Unless you want to build one for the sake of doing it yourself, there no point in making it from scratch. At the end of the day, this will take you more time, it will be bigger, and the overall cost will probably be larger than a ready to use DC/DC converter, for instance:
RECOM RI-0512S , 2W , 167 mA ouput ($7.60 at mouser)
TracoPower TMH 0512S, 2W , 165 mA ouput ($8.26 at farnell)
Depending on what you plan to power with that, you might consider regulation and electrical isolation.
- regulation to make sure the output stays at 12V as long as the load consumption stays within the specs.
- isolation if you plan to power a device which is somehow connected to the mains as well. That way you wont fry your computer if your computer and the device are not on the same phase.
Beware, you are not supposed to draw more than 100mA from an USB port unless you have some USB logic able to ask for more. In real life, stealing 500mA from USB will work on most regular computers, but you may have unpleasant surprises on some cheap mini-PC and some laptops.