simply ‘embrace’ it?
{% if states('sensor.ble_weight_mi_scale2') in ['unavailable','unknown'] %}
{{states('sensor.weight_sensor')}}
{% else %}
{{states('sensor.ble_weight_mi_scale2')}}
{% endif %}
and @typxxi, don’t use the =, but :
value_template:
see the legacy template docs or re-write the above in the new template: format