Three-dimensional porous MXene/carbon nanofiber (CNF) nanocomposites were prepared by assembling environmentally-friendly and inexpensive bacterial cellulose (BC) gel sheets as a carbon source with novel two-dimensional MXenes nanoplate clusters and pyrolyzing the composite. The structure, morphology, and electrochemical properties of MXene/CNF was characterized using scanning electron microscopy, transmission electron microscopy, X-ray diffraction, X-ray photoelectron spectroscopy, and electrochemical techniques. The experimental results revealed that the MXene/CNF nanocomposites had excellent electrical conductivity, large specific surface area, abundant active sites, and excellent electrochemical properties. The sensitive electrochemical determination of chloramphenicol (CAP) was achieved by constructing an electrochemical sensor using the MXene/CNF composite. The response current values of the MXene/CNF sensor exhibited a good linear response with CAP concentration ranging from 0.03–25 μM, with a low detection limit of 9 nM. In addition, the sensor demonstrated good repeatability and reproducibility with relative standard deviations of 2.94 and 3.29%, respectively. Remarkably, the developed sensor was successfully used for the real-time detection of CAP in milk and jasmine tea beverage and satisfactory rates were obtained.