Grant permission for custom role from hook_install programmatically
Try this:

use Drupal\user\Entity\Role;

function mymodule_install() {
  $role_object = Role::load('my custom role name');
  $role_object-&gt;grantPermission('my custom permission name');
  $role_object-&gt;save();
}