They Have Not Rejected Thee, but Me, and We Have No King but Caesar
Old Testament: 1 Kings 8:7
And the Lord said to Samuel: Hearken to the voice of the people in all that they say to thee. For they have not rejected thee, but me, that I should not reign over them.
Old Testament, also: 1 Kings 12:12
But seeing that Naas king of the children of Ammon was come against you, you said to me: Nay, but a king shall reign over us: whereas the Lord your God was your king.
New Testament: John 19:15
But they cried out: Away with him; away with him; crucify him. Pilate saith to them: Shall I crucify your king? The chief priests answered: We have no king but Caesar.
The connection
The request at Ramatha is reasonable on its face. Samuel is old, his sons take bribes, and the elders ask for a king to judge us, as all nations have. God does not treat it as an administrative complaint. He tells Samuel the refusal is not of the prophet but of Himself, that I should not reign over them, and then grants it anyway, with the price itemised in advance: your sons conscripted, your fields taken, your servants his. The people hear the whole warning and answer, Nay: but there shall be a king over us. Samuel returns to it later, at Galgal, in one clause that names what was actually traded, whereas the Lord your God was your king. Centuries on, the same question is put again, and this time by a foreigner holding the power the elders had asked for. Pilate asks, shall I crucify your king, and the answer given is the sentence Ramatha was always working toward: we have no king but Caesar. What was implicit in the request for a king like the nations is now explicit and complete, said aloud, in the presence of the King, as the reason for handing Him over. Augustine notes the legal force of it, that once those words were spoken Pilate could not release Him without appearing to act against Caesar.
Moral sense
Wanting to be governed like everyone else is rarely felt as apostasy while it is happening. It is asked for as practicality, granted with the cost stated plainly, and only named for what it was much later.
Anagogical sense
The kingship refused at Ramatha and refused again before Pilate is the one finally seen unrefusable, when He that sitteth on the throne is called King of kings and Lord of lords.
The Fathers
St Augustine, Tractates on the Gospel of John, Tractate 116, sect. 9, on the force of the words: once the chief priests had said "We have no king but Caesar," Pilate would "have every appearance of acting against Caesar" if he released a man condemned before him as a rival king, and so "delivered he Him therefore unto them to be crucified."
Warrant
John 19:15 does not cite 1 Kings 8:7, and the Gospel makes no reference to Ramatha. The connection rests on the two scenes putting the same choice in the same terms, a rejection of God as king expressed as a preference for a human one, with Samuel naming the exchange outright in 1 Kings 12:12. The words at the Praetorium are attributed by John specifically to the chief priests present, and the Catechism is explicit that no collective guilt for the Passion may be charged against the Jewish people of that time or any other.
Catechism of the Catholic Church, paragraph 597.