You should first understand that Wordpress user roles are simple as set of capabilities. That being said, since you said you are creating a plugin, I like to think you are no stranger to code and hence not afraid to code your solution rather than using another plugin for this.
This code should help you create a new user role and add custom capability to it.
<?php
// create a new user role
function wpeagles_example_role()
{
add_role(
'example_role',
'example Role',
[
// list of capabilities for this role
'read' => true,
'edit_posts' => true,
'upload_files' => true,
]
);
}
// add the example_role
add_action('init', 'wpeagles_example_role');
To add a custom capability to this user role use the code below:
//adding custom capability
<?php
function wpeagles_example_role_caps()
{
// gets the example_role role object
$role = get_role('example_role');
// add a custom capability
// you can remove the 'edit_others-post' and add something else (your own custom capability) which you can use in your code login along with the current_user_can( $capability ) hook.
$role->add_cap('edit_others_posts', true);
}
// add example_role capabilities, priority must be after the initial role definition
add_action('init', 'wpeagles_example_role_caps', 11);
Futher reference: https://developer.wordpress.org/plugins/users/roles-and-capabilities/