You can use $bytes(number, b) to do this already (although admittedly it's not it's intended purpose). For example:
//echo -a $bytes(10000, b) echoes 10,000


Spelling mistakes, grammatical errors, and stupid comments are intentional.