Fossil group origins: V. the dependence of the luminosity function on the magnitude gap