The soldier groaned in pain.

Literal

Soldier [topic-は] pain [cause-で] groaned.

で here marks the cause or reason — 'because of pain.' This causal use of で is distinct from its locative or instrumental uses. うめく (to groan, to moan) is an evocative verb often used in literary contexts.