Perhaps an ancient Roman legion with a ballista - and balls of steel - could do some damage.
But you can only stop a herd of elephants that work together with modern technology.
The only early walls that can stop elephants would would be castle walls and thicker, and those are major projects that you'd have to undertake while getting tusked and stomped. Maybe ditches would work better, or caltrops.