It does indeed mean that the protagonist suffered 12 years of slavery: he was (for) 12 years a slave, or (as it would more commonly be phrased) he was a slave for 12 years.
This construction can be used with durations or multiplications followed by a noun, and it indicates how long or how many times someone is or was something.
Other more or less well-known uses of the construction include Hercule Poirot who frequently at some point when the plot is nearing its denouement exclaims something along the lines of, “Ah, but I have been 20 times an imbécile!”.
It is most commonly used in verbless clauses used adverbially to describe the subject of the sentence:
Five times a nominee, she has finally joined the ranks of Oscar Award winners.
In these cases, the implied verbal structure is “Having been a nominee five times”, vel sim. In your case here, where there is no sentence at all, only a movie title, it is not really fair to say that there is an implied verb at all—the construction just means “a slave for 12 years”.