Sure, I've done something similar in a script I once made.
This is if you want it to revert the password to what is set in the server soldat.ini settings:
procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
var
Password: string;
begin
if (NumPlayers <= 1) then
begin
Password := ReadINI('soldat.ini','NETWORK','Game_Password','');
if (Password = '') then
Command('/password')
else
Command('/password ' + Password);
end;
end;
This does exactly what you asked for:
procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);
begin
if (NumPlayers <= 1) then
Command('/password');
end;
I'm not sure if they work with 2.6.4, I haven't had a need to download the latest server as of yet, but tell me if you encounter any problems (paste the errors as they are written in the console/logs, I did modify them from what I used in my script in order to make them standalone).