Cuting or controling material at specific point

Hello guys!
I have some ideological problem with solving some issue.
In my game I have a simple static mesh - let’s say a cylinder with a dynamic material. The height of the mesh must decreasing during the game. But there is an event which makes the cylinder a bit taller. So I have to highlight the extra part for a moment by changing its colour to ex green. What is more when the cylinder becomes really small I have to set it red.

Have you got any ideas how to reach this? We had some ideas to have two cylinders and munipulate parameters in the second one but we have to change the height of the extra part too.
Is there any way to change the UV map of the mesh dynamically?

Regards

Creating a procedural mesh would be a solution so you can manipulate UVs as you want.
Else you may use WorldAlignedTexture on material.