You could use a utility script like this
And amend to fit your purpose
#!/usr/bin/env bash
reboot="(ucode|cryptsetup|linux|nvidia|mesa|systemd|wayland|xf86-video|xorg)"
if [[ $(which yay) =~ (yay) ]]; then
updates=$(checkupdates; yay -Qua)
else
updates=$(checkupdates)
fi
echo "$updates"
if [[ $updates =~ $reboot ]]; then
echo "Updating possibly requires system restart ..."
fi
if [[ $updates =~ 'cryfs' ]]; then
echo "Oh-oh - watch out for cryfs update ..."
fi