Hi there, you would need to use a third-party app, as such functionality is not provided by the OS itself. The OS itself only provides the standard AOSP toggle to disable background data under app permissions.
For an app to provide such functionality, it would need to use the VPN slot, I believe RethinkDNS has such functionality.