Re: Dynamic Search Ads
I don't think there's a direct method to excludes pages that result in 404. Excluding simply 404 page will not exclude the broken URLs.
I would advise you to look into to your Webmaster Tools data and find the broken URLs. If you can fix them, it's great. If you can't, exclude these URLs using Dynamic Search Ads Exclusions. You can access it at your campaign > Auto targets. Scroll down to find 'Exclusion' option.
All the best!