Programmatically Restrict WordPress from using certain URLs or sub-directories

The easiest way in WP would be to use wp_unique_post_slug hook.

It takes 6 params:

apply_filters( 'wp_unique_post_slug', string $slug, int $post_ID, string $post_status, string $post_type, int $post_parent, string $original_slug )

So you can target given URL and modify the slug would conflict.

Let’s say you want to prevent WP from using website.com/eat address. All you need to do is to disable eat as slug value.

add_filter( 'wp_unique_post_slug', 'prefix_wp_unique_post_slug', 2, 6 );
function prefix_wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) {
    if ( 'eat' == $slug ) {
        // change it to something else
        return $slug .'-2';
    }
    return $slug;
}