import re
strings = ['PT1M6S', 'PT38S', 'PT58M4']
rx = re.compile(r'^PT(?:(\d+)M)?(?:(\d+)S?)?$')
for s in strings:
  print(s, ' => ', rx.sub(lambda x: f"{(x.group(1) or '00').zfill(2)}:{(x.group(2) or '00').zfill(2)}", s))