Update: QGIS 3.18 now has built in support for gradient color band legend items, so the previous workarounds are no longer necessary!
For earlier versions:
Another option is to add a rectangle shape to the composition, then style the rectangle using a gradient fill with the same color ramp as your raster. This can be done directly in QGIS, no image editing or html required.