We have explored it and found - how to create a content type by adding the YML files in the config/install directory of a custom module. The new content type will be created when we enable the module.
But we have a use case where we need to generate content types on saving a form. For eg: We have a custom form with a field called "Content-Type Name". On submitting the form, we need to create a new content type with that name.
We are not able to find any proper documentation for this in Drupal 8.