Here are a few examples on how to exclude some packages from being updated during yum/dnf update:
# yum update --exclude=PACKAGENAME
Exclude all kernel related packages during update:
# yum update --exclude=kernel*
Exclude gcc and java:
# yum update --exclude=gcc,java
Exclude all gcc and php related packages:
# yum update --exclude=gcc* --exclude=php*
In order to permanently exclude/disable updating of some specific packages you might want to update your dnf.conf or yum.conf eg:
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exclude=kernel* php* <---