Adding a prefix to PIVOT columns
The index use seems irrelevant to the concatenation.
The other 2 solutions are awkward.

Demo

create table t (x int,code varchar(100))

insert into t values 
    (1,'X'),(1,'X'),(1,'Y'),(1,'Y'),(1,'Y'),(1,'Z'),(2,'X'),(2,'X'),(2,'Y')




select  *
from    t pivot (count(code) for code in([x],[y],[z])) p



  Msg 265, Level 16, State 1, Line 13 The column name "x" specified in
  the PIVOT operator conflicts with the existing column name in the
  PIVOT argument.
  Msg 8156, Level 16, State 1, Line 13 The column 'x'
  was specified multiple times for 'p'.


select  *
from    (select x,'my_prefix_' + code as code from t) t 
            pivot (count(code) for code in([my_prefix_x],[my_prefix_y],[my_prefix_z])) p




+---+-------------+-------------+-------------+
| x | my_prefix_x | my_prefix_y | my_prefix_z |
+---+-------------+-------------+-------------+
| 1 | 2           | 3           | 1           |
+---+-------------+-------------+-------------+
| 2 | 2           | 1           | 0           |
+---+-------------+-------------+-------------+