My point is that, according to this particular zoning ordinance (and I suspect that some others mimic this one in some fashion), the lack of a required permit results in an ordinance violation.
I would not (and do not) jump to the conclusion that an ordinance violation creates an illegal use.
In my jurisdiction, for residential properties, new water heaters must be installed with a safety strap. Most are. Some are not (or the strap broke and has not been replaced).
I note that but I do not state that the SFR is an "illegal use" due to the violation.
Maybe the question that needs answered is "does an ordinance violation create an illegal use?" If not, what would create an illegal use?
This is the question. And here's the answer (mine, at least): A permissible use is a permissible use. A use allowed by the zoning, unrestricted (we call that a "use by right") is allowed.
In the OP's case, the use is an apartment. Presumably, as 12-units, it was legal. If the density does not allow for more than 12-units, and the alteration isn't grandfathered, then I would conclude that the use is now illegal. A 13-unit apartment building is not allowed on the site, and one could not be built. If I wanted to add a 13th unit and went to the city and applied for the permit to do so, they would deny me. 13 units are not "legally permissible" for my site. 13 units, as-is, fails the H&BU test in terms of legally permissible (as-is and as-vacant).
If, however, there is no density restriction and I could have 13-units on the site, then 13-units is legally permissible. As-vacant, it would be permissible to construct a 13-unit building. I'm good.
If 13 units are permissible and I've added an additional permit without permits when permits are required, then I have a legal use with an unpermitted alteration. The use is legally permissible, the alteration has not been permitted. I'm not changing the use or violating the allowable use-provisions, I've altered the building without the required permit. The remedy for this is to obtain the permit. If the use is allowed, it cannot be denied. The lack of permit may or may not have an impact on the value of that additional unit which should be analyzed.
The improvement (assuming 13 units is allowable) in its altered density is legally permissible. The lack of permit for the 13th unit needs to be disclosed.