This would have to be one of the most requested features in SCCM – at least from our clients.
https://docs.microsoft.com/en-us/mem/configmgr/core/get-started/2021/technical-preview-2106
To quote the specific part of the article:
On the Deployment Settings page of the Deploy Software Wizard, configure the following options:
Action: Install
Purpose: Required
Enable Uninstall this application if the targeted object falls out of the collection
CB SCCM releases continue to deliver useful stuff.