Atmospheric temperature and mixing ratio profiles of terrestrial planets vary with the spectral energy flux distribution for different types of M-dwarf stars and the planetary gravity. We investigate the resulting effects on the spectral appearance of molecular absorption bands, that are relevant as indicators for potential planetary habitability during primary and secondary eclipse for transiting terrestrial planets with Earth-like biomass emissions. Atmospheric profiles are computed using a plane-parallel, 1D climate model coupled with a chemistry model. We then calculate simulated spectra using a line-by-line radiative transfer model. We find that emission spectra during secondary eclipse show increasing absorption of methane, water and ozone for planets orbiting quiet M0-M3 dwarfs and the active M-type star AD Leo compared to solar type central stars. However, for planets orbiting very cool and quiet M dwarfs (M4 to M7), increasing temperatures in the mid-atmosphere lead to reduced absorption signals, making the detection of molecules more difficult in such scenarios. Transmission spectra during primary eclipse show strong absorption features of CH4, N2O and H2O for planets orbiting quiet M0-M7 stars and AD Leo. The N2O absorption of an Earth-sized planet orbiting a quiet M7 star can even be as strong as the CO2 signal. However, ozone absorption decreases for planets orbiting such cool central stars due to chemical effects in the atmosphere. To investigate the effect on the spectroscopic detection of absorption bands with potential future satellite missions, we compute signal-to-noise-ratios (SNR) for a James Webb Space Telescope (JWST)-like aperture telescope.