remove_action('wp_head', 'wp_generator');
This code worked for me. I placed it inside my theme’s functions.php file. The same method works for removing other actions, such as
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'locale_stylesheet');
etc