The shear modulus G of two glass-forming colloidal model systems in d = 3 and d = 2 dimensions is investigated by means of, respectively, molecular dynamics and Monte Carlo simulations. Comparing ensembles where either the shear strain γ or the conjugated (mean) shear stress τ are imposed, we compute G from the respective stress and strain fluctuations as a function of temperature T while keeping a constant normal pressure P . The choice of the ensemble is seen to be highly relevant for the shear stress fluctuations µF(T ) which at constant τ decay monotonously with T following the affine shear elasticity µA(T ), i.e. a simple two-point correlation function. At variance, non-monotonous behavior with a maximum at the glass transition temperature Tg is demonstrated for µF(T ) at constant γ. The increase of G below Tg is reasonably fitted for both models by a continuous cusp singularity, G(T ) ∝ (1 − T /Tg) 1/2 , in qualitative agreement with some recent replica calculations. It is argued, however, that longer sampling times may lead to a sharper transition. The additive jump discontinuity predicted by mode-coupling theory and other replica calculations thus cannot ultimately be ruled out.