The open-source geospatial analysis library WhiteboxTools has a majority filter that works for single-band GeoTIFF images. You can download the library's compiled binaries from here, the project code repository is here, and source code for the majority filter tool is here. Instructions for how to call functions using Python can be found in the user manual. Here is an example of a Python script calling the majority filter tool:
from whitebox_tools import WhiteboxTools
wbt = WhiteboxTools()
wbt.work_dir = "/path/to/data/"
wbt.majority_filter("image.tif", "filtered.tif", filterx=15, filtery=15)
The following is an example of applying a 15 x 15 majority filter to a portion of a Landsat image, band 1:
I should also add the disclaimer that I am the developer of the WhiteboxTools library.