Is a Jewish king obligated to perform a death penalty if another Jew disobeys him for something trivial and if yes then is he absolutely obligated to go through with it or can he pardon him or forgive him at will or give him a lesser punishment?
Rav Shlomo Aviner kindly exacted beautifully that the Rambam (Hil. M'lachim 3, 8) precisely deals with your excellent question. He is careful to use the term (3 times!) "r'shut" [=is allowed, and not is obligated] and "im ratza" [=if he wishes] to kill even on slight infractions upon his honor, which is the national honor of Israel, as well as being the "representative" of the God of Israel. The transgressor deserves ["chayav", or is "obligated" to] death, but the king has the right to forego that, if he sees it counterproductive. Accordingly, we see throughout Tehilim that David often suffered those who insulted him, even though a king isn't allowed to forego his honor, for he calculated the more productive reaction, and that's his prerogative, and the greatness of David's humility (especially in those days of monarchy!, Resp. Rashba III, 238). Similarly David, on his deathbed, again recalculated (!) who should be punished now, and who not. On the other hand, Shaul is criticized for foregoing his honor too much (Yoma 22-23). As we approach King David's yahrtzeit on Shavu'ot, it's a good time to appreciate his greatness, and how difficult it is to be king, and humble, and especially in those days, and especially of the Jewish people!