You missed specifying what is less than 5.
{% elif value < 5 %}{{ value }}
Also you need to specify an {% else %} case for when the value is greater then or equal to 5, if you don’t the sensor will be undefined.
Also please format your posted config correctly in future.