Are you on Apache? Either in .htaccess or in <Directory> sections of the config file, put an
ErrorDocument blahblah
line in each directory where you want it to be different. You can't have <Directory> sections in htaccess, so you would have to make additional htaccess files for any subdirectories with rules of their own. Anything in a deeper directory overrides anything further up the line. (Except for mod_rewrite, almost everything in Apache behaves this way.)
The choice of ErrorDocument is determined by the URL of the not-found file. If you want something more complicated-- like a document determined by the referer rather than the URL itself-- you would have to create a dynamic error document. Make a single php-or-equivalent page in a single location, and code it to deal with any variables you want it to deal with. You would also need to do something fancier if your directories don't physically exist but are created by rewriting from, say, one central index.php page.
But for normal purposes, a static document is all you need. Note that the physical location of the
error document itself doesn't matter. You can have a /shoes-errors.html and a /pants-errors.html and a /codpiece-errors.html all living side by side in the same directory. (Mine's called /boilerplate/, because I have no imagination.)
Reminder! An error document is a special kind of rewrite; the user's browser "thinks" it's at the originally requested URL. So if the error document uses any external files such as css, make sure all links are absolute.