A functional limit theorem for locally perturbed random walks