The question was posed:
" How to convert generator to synchronous condenser"
This begs the question; Permanent conversion or alternating between generating kW and producing KVAR?
My answer is mainly with a permanent conversion in mind.
There are two issues with a conversion.
Supporting the shaft and starting.
Almost all diesel generators are single bearing machines.
If these generators are removed from the engine, there is no bearing on the drive end.
You must fabricate a bearing and an end plate to support the drive end of the rotor.
Many generators may be started as a synchronous motor, the damper winding acting as a squirrel cage winding.
If the generator will not start on the damper winding, it may be started with a VFD.
A much cheaper option is to use a pony motor to spin the machine up to speed and then sync to the grid.
All that remains is to replace a simple AVR with a VAR controller or set a more advanced AVR to VAR control.
That being said, I do know of one very large exception.
Running a diesel engine at light or no load is not generally considered good practice.
The engines have a tendancy to slobber or pump oil out the exhaust, but it can be done.
Case in point:
A city was originally supplied with power from a diesel generator plant.
Hydro power became available and the generator plant was mothballed.
As time passed and the city grew and electric usage per household grew, the capacity of the transmission line was reached.
Transmission line capacity is often limited by the ability of the transformer on-load-tap-changers to compensate for voltage drop in the transmission line.
This voltage drop is usually more reactive than resistive.
The diesel plant was taken out of mothballs and put into service as a synchronous capacitor station.
With the VARs being supplied locally the reactive voltage drop was reduced and the capacity of the transmission line was greatly increased.