In the redirect section of your .htaccess file just add the following line:
ErrorDocument 404 https://example.com/404/
Replace the url by the actual url of your dedicated 404 page as you would do for any other redirect.
Now all what’s left to do is to create the page in your CMS back end (or code one in html if you are running a static site).