How to change fieldset which is made via #theme_wrapper Drupal 7
I had to do this today on a Backdrop CMS site, but the problem and solution are exactly the same: 

The problem is that most theme wrappers only add markup around the outside of something else. But a fieldset also has a process function, and process functions are not automatically added for #theme_wrappers. 

The process function needs to run on the fieldset in order to take the #collapsible and #collapsed settings you add in the Form API to turn into the addition of the necessary CSS classes and JS library. 

That means that not only do you need to set the values for #collapsible and #collapsed, but you also need to add the #process function. See below for an example. 

/**
 * Implementation of hook_form_BASE_FORM_alter().
 * - Limits access to legacy fields.
 * - Collapses legacy fieldset.
 */
function mymodule_form_node_form_alter(&amp;$form, &amp;$form_state) {
  if (isset($form['field_images_inline'])) {
    $form['field_images_inline']['#access'] = user_access('administer nodes');

    // Add the collapsible and collapsed attributes.
    $lang = $form['langcode']['#value'];
    $form['field_images_inline'][$lang]['#collapsible'] = TRUE;
    $form['field_images_inline'][$lang]['#collapsed'] = TRUE;

    // Add the fieldset process function.
    $form['field_images_inline'][$lang]['#process'] = array('form_process_fieldset');
  }
}