My guess would be the comment. You cannot insert a YAML comment into a Jinja template. Jinja template syntax is to bracket the comment between {# and #}.
That’s not how you do comments in Jinja and your slicing method won’t return a single numeric value, which is required if you set a unit_of_measurement.
{% set heating_setpoint = states('sensor.st_00137716_temperature') | float(none) %}
{% if heating_setpoint is none %}
5 {# Default to 5 if sensor is unavailable #}
{% else %}
{% set temp = heating_setpoint + 10 %}
{% set clamped_temp = ([5, temp, 10] | sort)[1] %}
{{ clamped_temp }}
{% endif %}