Context. Gamma-ray emission in the TeV (10 12 eV) range has been detected by HESS from two X-ray binaries: PSR B1259-63 and LS 5039. In both, the early-type star provides large numbers of target photons for pair-production with TeV γ-rays. This results in a modulation of the γ-ray flux as the relative positions of the γ-ray source and companion star change with orbital phase for the observer. Aims. The extent to which this variable absorption can provide useful diagnostics for the location and nature of γ-ray emission is examined. Methods. The absorption spectrum and transmitted flux are calculated by integrating the yy cross-section along the line-of-sight, taking into account the orbit, the spectrum and the finite size of the companion star in LS 5039, PSR B1259-63 and LSI +61°303, a system similar to LS 5039 but still undetected at TeV energies. Results. In LS 5039, emission close to a black hole or a neutron star primary is considered. In both cases, the transmitted flux >250 GeV drops by an order-of-magnitude near periastron (0 = 0). A black hole yields a clear spectral signature in the average spectrum at ≈400 GeV. A neutron star yields more variability, with the spectral feature moving from 200 GeV (Φ = 0.1) to 3 TeV (Φ = 0.7). Only 20% of the flux is absorbed at Φ = 0.7, allowing for an almost direct view of the intrinsic spectrum. Low variability will require emission on large scales, more than 0.7 AU away to have <50% absorption in a jet. In LSI +61°303, significant absorption (up to 90% of the 100 GeV flux) is predicted only slightly before periastron, accompanied by a spectral hardening above 1 TeV. In PSR B1259-63, although 40% of the flux is absorbed before periastron, the large variability seen by HESS is due to the γ-ray emission process. Conclusions. The predictions made here are essential to distinguish variability in the emission of γ-rays from that due to absorption. A modulation would provide a novel way to constrain the γ-ray source. Its absence would imply that γ-ray emission occurs on large scales.