In single-particle entanglement (SPE) two degrees of freedom of a single particle are entangled. SPE is a resource that can be exploited both in quantum communication protocols and in experimental tests of noncontextuality based on the Kochen-Specker theorem. SPE can be certified via a test of quantum contextuality based on Bell inequalities. Experiments of Bell-type inequality violation by single-particle entangled systems may be affected by an analog of the locality loophole in this context, due to the presence of unavoidable nonidealities in the experimental devices which actually produce unwanted correlations between the two observables that are simultaneously measured. This issue is tackled here by quantitatively analyzing the behavior of realistic devices in SPE experiments with photons. In particular, we show how it is possible to provide a semi-device-independent randomness certification of realistic quantum random-number generators based on Bell-inequality violation by SPE states of photons. The analysis is further enlarged to encompass, with a Markovian model, memory effects due to dead time, dark counts, and afterpulsing affecting single-photon detectors, in particular when not dealing with coincidence measurements. An unbiased estimator is also proposed for quantum transition probabilities out of the collection of experimental data.