As long as you're resident in Germany, it's pretty easy. Just contact a local accountant or law firm and they can help you. Things will get complicated if you want to use the company as a way to obtain work visa a non-EU national, though, and check if your current visa allows you start a business/side business.
If you're not resident in Germany or the EU at all, it becomes more complicated and I'd go back to the drawing board and make 100% sure a German company is exactly what you need.