Theory of Feshbach molecule formation in a dilute gas during a magnetic field ramp