ScotRail has spent over £4m on rail replacement services in the nearly three years since it became nationalised, new figures show.