Wordpress has built in 404 and 403 template, it called in 404.php and 403.php in your template.
OR, You can also defined which page / action will load when specified error code sent by detected http response code, put this on your functions.php file:
function detect_response_header(){
if (http_response_code() == 403) {
// do some action here, include template file, redirect to outside wordpress environment (file that not WordPress not involved in your site) or whatever
}
}
add_action('init''template_redirect','detect_response_header');
ref:
https://codex.wordpress.org/Plugin_API/Action_Reference/init