You can do this by follow this step :
Go to :
/var/www/html/YourMagento/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php
Find this line :
$modulePaths = $this->componentRegistrar->getPaths(ComponentRegistrar::MODULE);
Replace this below line and add path of the module which you want to compile like this :
$modulePaths = ['CompanyName_ModuleName' => '/var/www/html/YourMagento/app/code/CompanyName/ModuleName'];
Make sure module register with thisCompanyName_ModuleName
in registration.php
file.
It's temporary solution for di compile single module. Remove di generated module folder and refresh cache.
Hope, It will helpful for you.
Reference