[Magisk] badabing2003:
You don't need to recompile the kernel, all you need is to edit the string, hexedit should be enough.

Of course you need to know the offset to edit (see the link provided above by @Umgak .

You can use this script to do the unpacking / decompressing / patching / flashing

If you have ventured into recompiling Kernel, I'm sure the script should be trivial for you to understand and use.

Run it once without specifying the offset, you'd get the kernel_unpacked

Look for the offset in it.

Then run it with setting the offset and what string to put.

#!/bin/sh

# ==============
# Usage function
# ==============
usage() {
echo "Usage: $0 [OPTIONS] replacement_text"
echo "OPTIONS:"
echo " -offset OFFSET Set the offset for patching the kernel (can be decimal or hex format. Default: $default_offset)"
echo " -bootfile FILE Set the bootfile to patch (default: auto-extract)"
echo " -flash Flash the patched boot image after patching (default: $flash)"
echo " -compression COMP Set the compression method for the patched kernel (default: auto-detect)"
echo " -slot SLOT Set the slot to flash the patched boot image (default: auto-detect)"
echo " -magiskboot PATH Set the path to magiskboot binary (default: $default_magiskboot)"
echo " -check_kernel Check if the kernel is in the known banned list and exit"
echo " -h Show usage information"
echo
exit 1
}

# =======================
# Slot detection function
# =======================
detect_slot() {
if [ ! -d "/dev/block/bootdevice/by-name/" ]; then
echo "ERROR: Boot partition directory not found."
return 1
fi

if [ -e "/dev/block/bootdevice/by-name/boot" ]; then
echo "boot"
elif [ -e "/dev/block/bootdevice/by-name/boot_a" ] && [ -e "/dev/block/bootdevice/by-name/boot_b" ]; then
slot_suffix=$(getprop ro.boot.slot_suffix)
if [[ -n "$slot_suffix" ]]; then
echo "boot$slot_suffix"
else
current_slot=$(getprop current-slot)
if [[ -n "$current_slot" ]]; then
echo "boot$current_slot"
else
echo "ERROR: Cannot get active slot."
return 1
fi
fi
else
echo "ERROR: Unexpected boot partition configuration."
return 1
fi
}

# ============
# check_kernel
# ============
check_kernel() {
kernel_info=$(uname -a)
echo $kernel_info
for banned_kernel in "${BANNED_KERNELS[@]}"; do
if [[ $kernel_info == *"$banned_kernel"* ]]; then
echo "The kernel is banned: $banned_kernel"
exit 1
fi
done
echo "The kernel is not banned as of the writing of this script."
echo
exit 1
}

# --------------
# Default values
# --------------
default_offset=
default_magiskboot="/data/adb/magisk/magiskboot"
flash=false

# List of banned kernels
BANNED_KERNELS=(
'-AICP'
'-arter97'
'-blu_spark'
'-cm-'
'-crDroid'
'-crdroid'
'-CyanogenMod'
'-Deathly'
'-EAS-'
'-eas-'
'-ElementalX'
'-Elite'
'-franco'
'-Lineage-'
'-lineage-'
'-LineageOS'
'-lineageos'
'-Noble'
'-Optimus'
'-SlimRoms'
'-Sultan'
'-sultan'
)

while [[ $# -gt 0 ]]; do
key="$1"

case $key in
-h)
usage
;;
-check_kernel)
check_kernel
;;
-offset)
offset="$2"
shift
shift
;;
-bootfile)
bootfile="$2"
shift
shift
;;
-flash)
flash=true
shift
;;
-compression)
compression="$2"
shift
shift
;;
-slot)
slot="$2"
shift
shift
;;
-magiskboot)
magiskboot="$2"
shift
shift
;;
*)
text="$1"
shift
;;
esac
done

offset="${offset:-$default_offset}"
magiskboot="${magiskboot:-$default_magiskboot}"

# If bootfile is not specified, auto-extract it
if [[ -z "$bootfile" ]]; then
slot_output=$(detect_slot)
if [ $? -ne 0 ]; then
echo "Error: $slot_output"
exit 1
fi
slot=$slot_output
bootfile="boot.img"
echo
echo "Extracting boot image from $slot partition ..."
dd if="/dev/block/bootdevice/by-name/$slot" of="$bootfile"
fi

# -------
# Cleanup
# -------
echo
echo "Cleaning up ..."
rm -f kernel kernel_to_patch kernel_unpacked ramdisk.cpio new-boot.img
echo

# -----------
# Unpack boot
# -----------
echo "Unpacking $bootfile ..."
"$magiskboot" unpack -n "$bootfile"
echo

# -----------------
# Decompress kernel
# -----------------
echo "Decompressing kernel ..."
"$magiskboot" decompress kernel kernel_unpacked
echo

# ---------------------------------------------
# If Offset is not specified stop at Decompress
# ---------------------------------------------
if [[ -z "$default_offset" && -z "$offset" ]]; then
echo "ERROR: Offset not specified."
usage
fi
# convert offset to decimal if it is in hex format
if [[ $offset == 0x* ]]; then
offset_dec=$((16#${offset#0x}))
else
offset_dec="$offset"
fi

# --------------------------
# Check if patch text is set
# --------------------------
if [[ -z "$text" ]]; then
usage
fi

# ------------
# Patch Kernel
# ------------
echo "Patching kernel"
cp -f kernel_unpacked kernel
printf "%s" "$text" | dd of="kernel" bs=1 seek="$offset_dec" conv=notrunc
echo

# -----------
# Repack boot
# -----------
echo "Repacking $bootfile"
"$magiskboot" repack "$bootfile"
echo

# -----
# flash
# -----
if [ "$flash" = true ]; then
slot=$(detect_slot)
echo "Flashing new-boot.img to $slot ..."
dd if=new-boot.img of="/dev/block/bootdevice/by-name/$slot"
echo
fi

echo "Done!"
echo

UPDATE:

Added -check_kernel option to see if it is in the known banned list.