You can create a new backend without any server (which will cause a 503 error), and use a custom 503 errorfile for this, generating the 404 error (custom error files include HTTP response and header, not just payload).
For example:
frontend www-in
default_backend generate_404
backend generate_404
errorfile 503 /etc/haproxy/generate_404.http
Than create that file as per errorfile docs.