If you cannot use the Azure Dynamic Distribution Group filter for Exchange online. Use the CustomAttribute field as a staging will be the most suitable workaround for your tenant. (The best one is finding whether there exist suitable filer field for Exchange online: -RecipientFilter, there exist may fields for using)
If there doesn't exist suitable filter for "-RecipientFilter", you may need to run your script to modify CustomAttribute for copy relationship between Azure AD and Exchange online. The command below may could improve some efficiency (Force Exchange online Dynamic Distribution Group update members based on the filter that you created):
Set-DynamicDistributionGroup -Identity <DDGIdentity> -ForceMembershipRefresh
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.