It’s actually a function of energy released. The earthquake can get bigger if the fault slip is larger. A magnitude 12 quake is technically possible but requires an entire hemisphere to slip 500 meters. There’s a really interesting paper that takes the moment magnitude scale to its logical extremes.
PDF warning: https://www.fujipress.jp/main/wp-content/themes/Fujipress/pd...