It’s possible to do that procedurally … but not easy. Basically you need the UVs to run in a straight line so you can apply a linear gradient. To do that you would have to sweep a spline segment along the inner shape and use the outer shape as a rail spline.
Then you’d have to figure out how to extrude that shape without messing up the UVs….
Much easier just to create the gradient in PS or AI and project it from the top.