Well hey, I played with the source and somehow managed to make a lockteam cvar and it works.
Basically, I think what I did is bypass the PutClientInServer when the cvar is enabled when client tries to pick a team. It's pretty messy right now cos I don't exactly know what the code means, I just copied/modified a line or 2. I don't know how to put a default value in it and there's no messages at all when it gets enabled or disabled.
It only works when there are teams (that's perfect but purely accidental), has to be tdm or ctf and server must disable auto-join when players press "jump", and instead use the selecteam menu. Teamlock disables itself when a map starts, which is great, I think it's because I added
cvar_set("teamlock", "0"); in
ResetGameCvars but there's a message in server console that says "Cvar_Set: variable teamlock not found" everytime a map starts, so it might be an accidental bonus again at this point

. So it's obviously not done right, but it's a start.
Thanks a lot to pavlvs for letting me test it on his server.
Is this useful?