You typically cap this by some metric/tables based on the suit's magnitude ("I'm being sued for $50k") and court events (e.g., adjust hourly for "representation" in court based on how much you're sued for, and then just multiply the table value for that suit-value-range with the hours in court, add bonuses for court stuff that didn't require anyone to personally show up (i.e., mail/fax suffices)).
That's afaik how it's down in Germany.
Alternatively, you could cap the amount the looser pays to what they themselves payed, devising some sort of scheme to prevent exploits around lawyer-on-retainer/permanently-hired-lawyer on a large-entity's side.