It's unclear whether you've read up on CA landlord tenant info in general, and SFO ordinances in particular.
As for the lease saying "no unauthorized alterations", while you don't bother to mention the context, this typically refers to improvements or alterations like painting, etc. Does lease say anything about your not being authorized to change locks? If not, feel free. Let the landlord address it in landlord-tenant court if it has a problem.
"3.) If they cannot change the key legally, and they are discovered to have done so illegally, can they avoid eviction?"
There's a concept of a notice to cure a breach, and I suspsect a landlord wouldn't successfully get a court to agree eviction is warranted even if you did ignore a lawful demand to cough up a copy of a key. The court would simply, at worst, likely order you to cough up a key.
"How difficult would it be to get a court to authorize the tenants to change the keys and not give the landlord the new key?"
Have no idea how backed up your local landlord-tenant court might be. Meanwhile, might be a good idea for folks to install a little nanny-cam like device and send landlord a letter that no non-emergency access by maintenance is authorized when you aren't home unless and until the security issue is addressed. It may be that maintenance wasn't safeguarding any master key properly (assuming there is such a thing) and it was copied ... or not (wouldn't have to "force" entry to burglarize an apartment without a master key -- you'd just need a basic competence picking simple locksets).