That would be determined by the text-to-speech engine/voice you're using.
Oddly, at least on my machine, "Microsoft David Desktop" pronounces it as "5 gee", whereas "Microsoft Zira Desktop" pronounces it "5 grams"
Some text-to-speech providers may offer settings to change this behavior, but Microsoft does not, as far as I'm aware, for the mentioned voices.
SSML may offer markup that alters the pronunciation, however if upper-casing the text also works, the latter would arguably be the simpler option.