Yeah It will do. I have done it on my site. Check it out at http://www.free-ebooks-junction.com give some file name like falsefilename.php. See what types of ads are displayed on this page
If according to terms, it is not allowed... https://www.google.com/adsense/static/en_US/LocalizedTerms2.html 5. Prohibited Uses - (v) display any Ad(s), Link(s), or Referral Button(s) on any error page, on any registration or "thank you" page (e.g., a page that thanks a user after he/she has registered with the applicable Web site), on any chat page, in any email, or on any Web page or any Web site that contains any pornographic, hate-related, violent, or illegal content; There are some grey areas for the terms though; as trichnosis mentioned, if there is content on that page, it shouldn't be a problem. Besides, some CMS these days used the same template for content page and 404 page; if we are putting an ad unit at the header, chances are we are likely to show the ad on the 404 page as well. I won't worry about having an ad on 404 page unless it is done deliberately. When in doubts... the best way is always to email Google for clarification.