Done correctly, it should not make any difference, the optimizer is smart enough to reuse expressions.
But your CTE will not work that way - it still needs the group by in the CTE itself, and you have not gained anything.
The ad-hoc view would look like this:
select sum(ColA), sum(ColB), MyVar from
(SELECT ColA, ColB,
CASE @MyVar
WHEN 1 THEN 'XXX'
WHEN 2 THEN 'XXX'
WHEN 3 THEN 'XXX'
WHEN 4 THEN 'XXX'
END MyVar
FROM MyTable) v
group by MyVar
The CTE is the same.