How to pass a custom Form to a Twig template
This structure will not work with the autoloader right now - your namespaces and directory structure needs to follow these PSR-4 standards. (In particular, setting a namespace in your .module will cause Drupal to not find your hooks, which must be in the global namespace.)

I'm not sure I understand your use case fully, but it sounds like you want to:


Create a form.
Create a route that serves this form.
Render the form with a custom template.


For the first, your form class should be something like this (and must be saved in a file matching the class name under modulename/src/Form/{ClassName}.php):

namespace Drupal\modulename\Form;

use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;

class MyModuleConfigForm extends ConfigFormBase {

  public function getFormId() {
    return 'modulename_settings';
  }

  public function getEditableConfigNames() {
    return ['modulename.settings'];
  }

  public function buildForm(array $form, FormStateInterface $formState) {
    // build the form
    $form['...'] = [
      //...
    ]; 

    parent::buildForm();
    return $form;
  }

  public function submitForm(array $form, FormStateInterface $formState) {
    $this-&gt;config('modulename.settings')
      // set the values from the form
      -&gt;set('...', $formState-&gt;getValue('...'))
      -&gt;save();

    parent::submitForm($form, $formState);
  }

}


For the second part, you need a modulename.routing.yml file that looks something like this:

modulename.settings:
  path: '/admin/config/mymodule'
  defaults:
    _form: '\Drupal\modulename\Form\MyModuleConfigForm'
  requirements:
    _permission: 'administer site configuration'


(This is for admin configuration forms, since you mentioned ConfigFormBase. If you want a more general form and open it to anonymous users, extend FormBase instead and put _access: 'TRUE' in the route requirements.)

Finally, for the third part, you need to create your theme hook in modulename_theme(). (Your code already works, although the template key is superfluous as it matches the default.)

Then, modify the buildForm() as follows:

  public function buildForm(array $form, FormStateInterface $formState) {
    // build the form
    $form['...'] = [
      //...
    ]; 

    parent::buildForm();

    // *After* parent call.
    $form['#theme'] = 'modulename_form';

    return $form;
  }