Generate installed modules into a composer.json for existing site: I need to manage via Composer, not via UI
Composer Generate is a Drush extension. It can be used either with Drupal 7 or Drupal 8. Considering that the latest release available on drupal.org is dated Febrary 25, 2016, it's probable it is not compatible with the Drush version you would be use on your site.

The project page for Composer Generate suggests using the Composerize module, which is available for Drupal 8.


  This module can generate a composer.json from your installed Drupal code base, which can be used to regenerate that code base by running composer install.


Be careful of the warning reported in the project page.


  This module is still in development. It supports very basic Drupal 8 setups, but there are many necessary features it still lacks (e.g., support for patches, JavaScript libraries, distributions, etc). We're working on all that stuff, but this module is definitely not ready for prime time.


The module is supported by Acquia, and the development version has been updated on March 20, 2018.

Alternatively, as the project page suggests, you could use Composerize Drupal, a Composer plugin for converting a non-Composer-managed Drupal site to a Composer-managed Drupal site.