Of course he can play as CM, I think besides the CB role he can play in any position on the pitch and be very good at it and he already proved it.
The main reason Pep is playing him in the front 3 is more down to earth, he is one of the few who can reliably score goals, and that is the #1 problem a manager has to solve.
When we had Aguero and Sterling scoring 30+ a season he was played in midfield, but when those two sources dried up Pep looked for other sources for goals including Foden. Haaland is on his way to fill that gap but until we have a reliable front 3 that can score at will he will be playing where he is needed the most, and that is in front.