You can hook to the wp_login_errors
filter.
add_filter('wp_login_errors', function($errors, $redirect_to){
if(isset($errors->errors['incorrect_password']) &&
in_array('custom_role', (array) get_user_by('login', $_POST['log'])->roles)){
$errors->errors['incorrect_password'][0] = 'Custom message';
}
return $errors;
}, 10, 2);
EDIT:
This should work with WooCommerce login form or any other form that implements wp_signon
:
add_filter('authenticate', function($user, $username, $password){
if(is_wp_error($user) &&
isset($user->errors['incorrect_password']) &&
in_array('custom_role', (array) get_user_by('login', $username)->roles)){
$user->errors['incorrect_password'][0] = 'Custom message';
}
return $user;
}, 21, 3);