Go to where you dropped the weapon, crouch, and repeatedly press Use. Move the mouse while pressing Use. The weapon may be picked up, though it can fail if it is stuck too far inside the wall.