you can use the $chr(160) hard space instead of the space.
or, since the extra spaces in a string of consecutive spaces are suppressed, you can insert a control code between consecutive spaces to allow them to be displayed, since they're technically not consecutive spaces anymore.

//var -s %string abc $chr(32) def | msg $chan $replace(%string, $+($chr(32),$chr(32)) , $+($chr(32),$chr(2),$chr(32),$chr(2)) )