It’s an amusing idea. Unfortunately, solar panels would not pay for themselves, let alone pay for the wall as well.
And, as pointed out, they would be an obvious target for angry stone throwers.
Yeah solar is definitely not a moneymaker.
Solar panels are attractive to selfish environmentalists and repulsive to physics majors and businessmen. Solar panels take 75 years to pay off.