You can give your class a method __format__; in this case, just call the overridden version:
def __format__(self, spec):
spec = spec or ',.2f'
return '$' + super().__format__(spec)
From related documentation:
format() , str.format(), "" . format_spec - , . format_spec __format__(), , .
__str__ __repr__ , , '$' , __format__ ( format(self, ...)).
:
>>> from decimal import Decimal
>>> class Money(Decimal):
... def __format__(self, spec):
... spec = spec or ',.2f'
... return '$' + super().__format__(spec)
...
>>> m = Money("123.44")
>>> print("Amount: {0}".format(m))
Amount: $123.44
>>> print(f"Amount: {m}")
Amount: $123.44