For your information, factory resetting an Intel-based MacBook Pro won't wipe any data stored on your iCloud drive if you set it in the right way, it merely deletes the settings and files stored on your computer's hard drives. You can factory set your Mac without wiping iCloud data in two steps: allow keep a copy of the iCloud files and wipe your Mac hard drive.
Follow these steps to wipe your MacBook Pro without deleting any data stored on iCloud.
Step 1: Keep a copy of the iCloud files when signing out of your iCloud
If your Intel-based MacBook Pro runs macOS Catalina or later versions, you should select the Apple menu > System Preferences > Apple ID, choose Overview at the left sidebar, then click Sign Out.
If your Intel-based MacBook Pro runs macOS Mojave or earlier, you should select the Apple menu > System Preferences, then directly click on iCloud > Sign Out.
When asked whether to keep a copy of the iCloud files on your Mac, allow it. By enabling this request, you can access all your iCloud data on your new M1 Mac.
Step 2: Wipe your MacBook Pro hard drive
- Completely shut down your Intel-based MacBook Pro.
- Restart it and hold down the Command + R keys simultaneously until you see the Apple logo or a spinning globe, it'll make your Mac enter into macOS Recovery Mode.
- Click Disk Utility > Continue.
- Right-click on Macintosh HD - Data (or macOS - Data) at the left column of the Disk Utility window, then click on Delete APFS Volume.
- Select Macintosh HD (or macOS) and click the Erase button.
- Name the new volume, select APFS as the format, and GUID Partition Map as the Scheme, then click Erase again.
- Choose the Delete Volume button.
Read more: How to Factory Reset M1 Mac (MacBook Air/Pro, Mac mini, iMac)