I think you've asked the wrong question, but I'll answer it as posed ("How can I define a legend with gradient background colors?").
You can use a STYLE to define a gradient background for your legend:
But I think your question is really about adding gradient fill to table cells, and my only suggestion for that is to use <back> (see comment above), but the fact it doesn't fill the whole cell probably makes it not suitable for you. Although by using monospace and right padding with spaces, you can get close:
or