Try all the different possible ways to format it and pick the shortest one length-wise, with preference given to larger units (e.g., prefer .55 B to 550 M, since they are the same length).
As for stripping leading zeros, one possible solution is checking if s[:2] == '0.'
and replacing it with '.'