you can force Wi-Fi to turn off when the display sleeps

By default, macOS keeps Wi-Fi on even when the display sleeps to allow background processes like downloads, notifications, and network services to continue running. However, you can force Wi-Fi to turn off when the display sleeps

Use a Terminal Command

sudo pmset -a tcpkeepalive 0

This disables network access when the system is in sleep mode, forcing Wi-Fi to disconnect. You will aso get this warning by macOS.

Warning: This option disables TCP Keep Alive mechanism when sytem is sleeping. This will result in some critical features like ‘Find My Mac’ not to function properly.

To revert it:

sudo pmset -a tcpkeepalive 1