How to format/display a negative number in time format

I’ve searched hi and lo but can’t see to find the answer to this.

Suppose I have a number that represents a quantity of seconds, such as 172.0749999999999. I know that I can display that in a MM:SS format with the following code:

      {% set total_seconds = 172.0749999999999 %}
      {% set minutes = (total_seconds // 60) % 60 %}
      {% set seconds = total_seconds % 60 %}
      {{ "%02d:%02d" | format(minutes, seconds) }}

This would display 02:52. If I change the same seconds number to a negative value instead, how can I display it as -02:52? I can’t seem to figure it out.

If it’s always negative then this will work.
But if it could be both then you probably need to if it.

      {% set total_seconds = -172.0749999999999 %}
      {% set minutes = (total_seconds / 60) | int %}
      {% set seconds = 60-total_seconds % 60 %}
      {{ "%02d:%02d" | format(minutes, seconds) }}