One of the main problems with this concept is, it's against the law.
Ohm's Law.
A solar collection field a mile square collects the energy in a small area and steps it up to high voltage for less lossy transmission to where it's needed. If the same amount is made 4' wide along the top of a wall, the equivalent area would top around 1,300 miles of wall. This increases costs and complexity, and takes away the economy of scale having the collection in a small area.
Then, the cost/watt and efficiency losses to make the panels invulnerable to the billions of rocks conveniently available to vandals along the wall, because the panels will need to be angled Southward.
I tried engaging Trump supporters on this, they scoffed at the very question of a cost/benefit analysis before deleting my thread.