I’d leave /etc/dnf/dnf.conf alone and put your local changes in local dropin file: /etc/dnf/libdnf5.conf.d/80-local.conf For example if you wanted to override fastestmirrors=true
then make the file contain:
[main]
fastestmirrors=true
See reference man dnf5.conf
under the section
DROP-IN CONFIGURATION DIRECTORIES