Understanding whether M dwarf stars may host habitable planets with Earth-like atmospheres and biospheres is a major goal in exoplanet research. If such planets exist, the question remains as to whether they could be identified via spectral signatures of biomarkers. Such planets may be exposed to extreme intensities of cosmic rays that could perturb their atmospheric photochemistry. Here, we consider stellar activity of M dwarfs ranging from quiet up to strong flaring conditions and investigate one particular effect upon biomarkers, namely, the ability of secondary electrons caused by stellar cosmic rays to break up atmospheric molecular nitrogen (N(2)), which leads to production of nitrogen oxides (NO(x)) in the planetary atmosphere, hence affecting biomarkers such as ozone (O(3)). We apply a stationary model, that is, without a time dependence; hence we are calculating the limiting case where the atmospheric chemistry response time of the biomarkers is assumed to be slow and remains constant compared with rapid forcing by the impinging stellar flares. This point should be further explored in future work with time-dependent models. We estimate the NO(x) production using an air shower approach and evaluate the implications using a climate-chemical model of the planetary atmosphere. O(3) formation proceeds via the reaction O+O(2)+M→O(3)+M. At high NO(x) abundances, the O atoms arise mainly from NO(2) photolysis, whereas on Earth this occurs via the photolysis of molecular oxygen (O(2)). For the flaring case, O(3) is mainly destroyed via direct titration, NO+O(3)→NO(2)+O(2), and not via the familiar catalytic cycle photochemistry, which occurs on Earth. For scenarios with low O(3), Rayleigh scattering by the main atmospheric gases (O(2), N(2), and CO(2)) became more important for shielding the planetary surface from UV radiation. A major result of this work is that the biomarker O(3) survived all the stellar-activity scenarios considered except for the strong case, whereas the biomarker nitrous oxide (N(2)O) could survive in the planetary atmosphere under all conditions of stellar activity considered here, which clearly has important implications for missions that aim to detect spectroscopic biomarkers.