No, "would rather" cannot always be replaced with "would prefer." In your example, "I would rather die than apologize to him" conveys a strong, dramatic choice, emphasizing personal feelings or principles.
If you replaced it with "I would prefer to die than apologize to him," it would sound awkward and less natural because "prefer" is typically used for more measured or practical comparisons, not extreme or emotional situations.
For dramatic statements like this, "would rather" is the better choice.