How can I restore macOS on a MacBook if all the data on the hard drive is wiped/corrupted?
So, first of all you need at least a 16 GB USB Drive.  Formatted as Mac OS Extended (use disk utility). And you need to open up the Mac App Store and download the macOS Mojave (or any version supported by your Mac) Installer.

Then follow this guide: https://support.apple.com/en-us/HT201372

After that you can eject your USB Drive.

Then when you need to reinstall macOS you shutdown your computer. Then hold down the option key then press the power button while holding down the option key until you see a boot picker. Then insert your USB Drive you created above. Use the arrow keys to select it then press enter. Then click disk utility and select your internal ssd and click erase. Then quit disk utility and click install macOS and follow the guide there.

Now your on your way to a working macOS install. Enjoy!