You can at the beginning but not at the end:
//var %a = $+($chr(32),a,$chr(32)) | echo -ag $replace(%a,$chr(32),-)
($replace is used to replace any spaces in the variable with dashes. This way you can see exactly where %a contains spaces)
More precisely, you can't have a variable with a single trailing space that is preceded by a non-space character; oddly enough, you can have more than one trailing spaces:
//var %a = $+(a,$chr(32),$chr(32)) | echo -ag $replace(%a,$chr(32),-)
or a single space (and nothing else):
//var %a = $chr(32) | echo -ag $replace(%a,$chr(32),-)
There are ways around this limitation. One is to use padding: just append a dummy character (or N dummy characters) when you set the var, then use $left(%var,-N) to retrieve its value without the dummy chars:
//var %a = $+(test,$chr(32)) X | echo -ag $replace($left(%a,-2),$chr(32),-)
Here the string " X" (2 chars) is appended when %a is set. Then when it is used, $left() removes the last 2 chars.