Word
"Word" does not necessarily mean literally what a grammarian calls a word i.e. a single word. In the sense "a command, an order, a behest; a direction, an instruction; an expressed request" it goes back to Old English, and the OED says it is "usually qualified by possessive or the".
A related form is "to send word", meaning to send an instruction, which goes back at least to Ælfric (c. 955 – c. 1010), Old Testament Summary: Judith (Corpus Christi Cambridge MS.) in B. Assmann, Angelsächsische Homilien u. Heiligenleben (1889) 110
Wycliffe's Bible (early version, 1382, 2 Kings xiv. 23) has "the word":
Þou forsoþe hast don þe woord of þi seruaunt.
("You indeed have done the word of your servant").
Say the word
The OED recognises "say the word" as an expression meaning "to give an order or instruction, esp. to someone who is expecting one; to state one's wishes (in response to a question or request)."
Their first citation is William Tyndale's, Exposicion vppon Mathew, c. 1533:
Kynge and Emperoure are their seruauntes: they nede but saye the worde, and their will is fullfilled.
It's also in the King James Version of the Bible, Ezekiel 12:25
For I am the Lord: I will speak, and the word that I shall speak shall come to pass; it shall be no more prolonged: for in your days, O rebellious house, will I say the word, and will perform it, saith the Lord God.
On the other hand it's not all religious. The OED has from 1560, Barnaby Googe's translation of Marcellus Palingenius's Zodyake of Lyfe:
If thou sayst the woord, we goe.
There's another instance from Thomas Heywood in 1631:
Shall I strike that Captaine? say the word, Ile have him by the eares.
There are other similar expressions too: Shakespeare's Henry V (1623) has "give the word" (iv. vi. 38):
Then euery souldiour kill his Prisoners, Giue the word through.
In summary, "say the word" is an expression meaning to utter a command. It arises naturally from the meaning of "(the) word", and there are many similar expressions, but "say the word" seems to have attained the status of an idiom in the 16th century.
Oxford English Dictionary, s.v. “word (n. & int.),” March 2024, https://doi.org/10.1093/OED/5831984793.