We have obtained low-resolution optical (0.7-0.98 micron) and near-infrared (1.11-1.34 micron and 0.8-2.5 micron) spectra of twelve isolated planetary-mass candidates (J = 18.2-19.9 mag) of the 3-Myr sigma Orionis star cluster with a view to determining the spectroscopic properties of very young, substellar dwarfs and assembling a complete cluster mass function. We have classified our targets by visual comparison with high- and low-gravity standards and by measuring newly defined spectroscopic indices. We derived L0-L4.5 and M9-L2.5 using high- and low-gravity standards, respectively. Our targets reveal clear signposts of youth, thus corroborating their cluster membership and planetary masses (6-13 Mjup). These observations complete the sigma Orionis mass function by spectroscopically confirming the planetary-mass domain to a confidence level of $sim$75 percent. The comparison of our spectra with BT-Settl solar metallicity model atmospheres yields a temperature scale of 2350-1800 K and a low surface gravity of log g ~ 4.0 [cm/s2], as would be expected for young planetary-mass objects. We discuss the properties of the cluster least-massive population as a function of spectral type. We have also obtained the first optical spectrum of S Ori 70, a T dwarf in the direction of sigma Orionis. Our data provide reference optical and near-infrared spectra of very young L dwarfs and a mass function that may be used as templates for future studies of low-mass substellar objects and exoplanets. The extrapolation of the sigma Orionis mass function to the solar neighborhood may indicate that isolated planetary-mass objects with temperatures of 200-300 K and masses in the interval 6-13-Mjup may be as numerous as very low-mass stars.