Yes, you can place carpet on top of walls and fences so that players can jump on top of them. This also assists in preventing animals and mobs from crossing. The reason is mobs never try to leap over fences and walls, even with a carpet above.