Please explain how breath testing is used to check whether bacteria exist in esophages?

You have it wrong. Breath testing to assess for bacteria in the stomach (h.Pylori) & in the small bowel (sibo=small intestinal overgrowth syndrome) is routinely used. Such tests assay for the byproducts of bacterial action on test substrate (thus indirectly indicating that live bacteria are present & at work in the gut). Bacteria are rarely clinically significant in the esophagus, & as such are not looked for there.