How important are recommendation letters when applying to a PhD in Germany? I am planning on applying to a PhD in engineering in Germany (either by contacting a group, which I will prioritize, or through a normal application at the graduate school).
The problem I currently face is finding good referees (by good, I mean respectable h-indices, for example).
For those acquainted with German academia: How much weight is put on the recommendation letters and, more importantly, the referrers when reviewing an application for a PhD position (more, or less, than in the US)?
For instance, if you had to rank these factors:

Letters of recommendation
Transcripts
Publications/internships
Statement of purpose

Where would the letters of recommendation be positioned?
You mention two different ways of applying: to a grad school and to (the head of) a group.
These ways of “getting in” are very different. Group leaders can, if they have the funds, normally hire whomever they want (if the formal qualification is given), and there is no standard process. For grad schools, there will typically be some committee that may have their own evaluation process.
A few points can be stated, though:

Letters of recommendation are a very recent occurrence in German academia. Some more senior professors may value them very little. If the group head is non-German, they are more likely to value them.

Transcripts are typically very important. The reason is that many PhD regulations require a more-than-average master’s degree. Hence, bad transcripts can be a show-stopper. But also they are often the best available information for how good an applicant is.

When applying directly to a group, you should have some courses on your transcript that are relatively close to the area in which the group is working on. You are expected to come with the knowledge needed to start researching right away, so this is important. Better have good grades in them.

If you have proper publications already, they help tremendously with your application. So they are, in a sense, most important. There is normally no expectation that an applicant has published research already. Note that papers in predatory journals have a good chance to count negatively, though.

If you apply to a group, it is more important to state why your interests align with those of the group. Be very concrete here, and do your homework. Groups with a lot of third-party funded projects will need PhD students to work on these projects, so if your statement of purpose being too concrete while not aligning with any of the projects would not be ideal.