Filter wp_unique_post_slug
. Make sure to add the callback with 6
as last argument to get the original slug. Then create a new unique slug as you need it, you get a lot of context information.
add_filter(
'wp_unique_post_slug',
function (
$slug,
$post_ID,
$post_status,
$post_type,
$post_parent,
$original_slug
)
{
// create a new unique slug based on $original_slug
return $slug;
}, 10, 6 );