Sample: https://github.com/HuskyHacks/PMAT-labs/tree/main/labs/2-4.BinaryPatching/SimplePatchMe
I wrote a note on my blog about patching x86 binaries. This concept has direct application during malware analysis, so this is a good methodology to learn. Check it out here!