CKEditor add custom class to table
I solved the problem by creating a custom CKEditor plugin.

This is the JS code, in case anyone find it helpful:

CKEDITOR.plugins.add('tableclass', {
  beforeInit: function (editor) {
    editor.ui.addButton('addtableclass', {
      label: 'Add table class.',
      command: 'addTableClass',
      icon: '/modules/custom/mymodule/icons/add.png'
    });
  },
  init: function (editor) {
    editor.addCommand('addTableClass', {
      canUndo: true,
      exec: function (editor, data) {
        const className = 'custom-class';
        var selection = editor.getSelection();
        var selectedElement = selection.getStartElement().$;

        if (selectedElement.localName === 'table') {
          selectedElement.classList.toggle(className);
        }
        else {
          selectedElement = selectedElement.parentNode;
          while (selectedElement &amp;&amp; selectedElement.localName !== 'table') {
            selectedElement = selectedElement.parentNode;
          }
          if (selectedElement.localName === 'table') {
            selectedElement.classList.toggle(className);
          }
        }
      }
    });
  }
});