We study the collective optical response of an atomic ensemble confined within a single-mode optical cavity by stochastic electrodynamics simulations that include the effects of atomic position correlations, internal level structure, and spatial variations in cavity coupling strength and atom density. In the limit of low light intensity the simulations exactly reproduce the full quantum field-theoretical description for cold stationary atoms and at higher light intensities we introduce semiclassical approximations to atomic saturation that we compare with the exact solution in the case of two atoms. We find that collective subradiant modes of the atoms, with very narrow linewidths, can be coupled to the cavity field by spatial variation of the atomic transition frequency and resolved at low intensities, and show that they can be specifically driven by tailored transverse pumping beams. We show that the cavity optical response, in particular both the subradiant mode profile and the resonance shift of the cavity mode, can be used as a diagnostic tool for the position correlations of the atoms and hence the atomic quantum many-body phase. The quantum effects are found to be most prominent close to the narrow subradiant mode resonances at high light intensities. Although an optical cavity can generally strongly enhance quantum fluctuations via light confinement, we show that the semiclassical approximation to the stochastic electrodynamics model provides at least a qualitative agreement with the exact optical response outside the subradiant mode resonances even in the presence of significant saturation of the atoms.