'Prime' isn't a surname but a title. Optimus, Rodimus, Sentinel, Alpha Trion — all are Primes, but none was born with the name. So how do you become one?

The Matrix chooses

In most versions a Prime is whoever the Matrix of Leadership chooses. It opens not for the strongest or eldest but for one able to bear responsibility for others. That's why Ultra Magnus couldn't open the Matrix, but young Hot Rod could.

The first Primes

The first Primes, the Thirteen, were created by Primus himself. The title's tradition and most legendary relics come from them.

A Decepticon?

In theory — yes: the Matrix looks at the spark, not the faction. The best-known counter-example is the Fallen, Megatronus Prime, who was himself one of the Thirteen but betrayed his brothers. So the title of Prime doesn't guarantee goodness, and lacking it doesn't mean evil.

Conclusion

One becomes a Prime through choices and deeds. That's why every passing of the Matrix in the franchise is a big event: a story not about power but about who is worthy to lead a people.