Is there anyway to upgrade some packages to the latest version?
For example from fedoras repo
There is not. Some packages rebase to a newer version (not the latest, usually) every 6 months on point releases, but beyond that, versions very rarely change in Rocky Linux. It is also not recommended to try to install fedora built packages on Rocky Linux.
dnf up does install the latest for Rocky.
The thing is that Enterprise Linux has its very own branch of packages, where “latest” is something else than in upstream.
See What is backporting, and how does it apply to RHEL and other Red Hat products?
When I need a newer version, I either go to the upstream source and look for a repo there that matches the OS I’m using, or I download the latest source RPM from Rawhide and attempt to rebuild it. That can take some developer skill in both understanding RPM and the language the package is written in. If you need that, you might be best off hiring someone to do that.
Replacing existing packages is usually dangerous. If you remove core package, you break the system.
Software Collections was el6/el7 method to install alternatives safely. The gcc-toolsets are still with that approach.