Yes they can! There is even a medical term for this, called “pyroflatulence”.
Farts (flatulence) are made up of a variety of gases, including carbon dioxide, hydrogen sulfide (which is responsible for the smell), methane, and nitrogen.
There have been cases documented in the operating room of farts being inadvertently ignited, causing injury to patients, and even one patient death.
The interested reader should be directed to the many youtube videos that demonstrate this phenomenon.