Languages like Japanese have different pronunciations for each character (in the kanji system in this case) , a kanji character can have up to 20 different pronunciations depending on the the word it is in. Is there or was there any language where each character is pronounced differently depending on the word it's in?
It is unlikely that in some language's writing system, each and every character is pronounced differently depending on the word it's in. For that to be true, it would mean that every character has at least two pronunciations. The implication of "what word it is in" is that what determines the pronunciation is the word, and not the general context (for instance, the Devanagari letter त is pronounced differently when it is combined with the letter ि). Kanji may have multiple readings, for example 明 can be myō or mei. Chinese also has multiple readings for a character. But not all characters are like that.
A candidate for such writing is the Phoenician alphabet, which (originally) only marked consonants, though of course the language did have vowels. So "𐤋" could represent [la, li, lu, l] and you would just have to know what the word is. But this is quite different from the situation with readings for Chinese characters. Still, it might be the kind of thing you are looking for.
There is, as a matter of fact!
Cuneiform ("wedge-shaped") was a writing system originally developed for the Sumerian language, then adapted for Akkadian, Hittite, and many other languages. But the adaptation process was not particularly consistent. Take this Sumerian glyph for example:
It originally meant the words an, "heaven", or An, "An, the god of the sky". But through synecdoche it could also mean diŋir, "deity". And when cuneiform started being used for sounds instead of words, it also meant the syllable
Then the Akkadians started using the writing system. In Akkadian, this sign was used for the words il ("god"), or šamû ("heaven"), taken straightforwardly from the Sumerian meanings. But, it could still be used for the syllable
/an/ from Sumerian, and now for the syllable
/il/ from Akkadian!
In fact, some signs, including this one ("DIŊIR", written in capitals to indicate the sign as opposed to any particular interpretation) could also be used as determiners, and not pronounced at all! When written before a name, this sign indicates that it's the name of a deity. This is mostly used for clarifying the huge mess of homophones created by this system.
It is the case in French. Such a differentiation is due to two distinct phenomena: assimilation & polyphonic letters.
An example of assimilations in French:
shop is transcribed in French "magasin" and is pronounced [maɡazɛ̃], but the word "oursin" is pronounced [uʁsɛ̃]. So the letter s can be pronounced [s] or [z].
An example of polyphonic letters in French:
The word "garage", meaning garage, is pronounced [gaʀaʒ]. This example shows that the letter g corresponds to two sounds [g] and [ʒ].
That can be generalised to other languages with old written traditions as English, Spanish and so on.
Let us add, ideograms (such the Kanji) are not an alphabetic writing system. Then, there is not relation between the characters and the signifier, instead the symbols are tied to the signified.
You're asking about a writing system, which is artificial. Even though language is learnt, it is considered natural. Language has meanings, and spoken language uses sounds to communicate those meanings. Written language converts the meanings to marks. One writing system may be used for multiple languages (Latin variants, Cyrillic, Devanagari, etc.), and one language may have multiple writing systems (Sindhi is written in Arabic, Devanagari, and Gujarati, as well as other historical scripts).
Your question is not so much about language, but a combination of language and writing. Language does not naturally have characters, but writing systems do. English is probably a good candidate language for its writing system. All "characters" and digraphs have at least two different pronunciations, although some may be viewed as being foreign, and not (yet) naturalised. As time goes on, this number could increase. English has been written for a long time and has had no spelling reforms, only standardisation. If we reformed English spelling, only people familiar with the old spelling would be able to read current English unchanged.
- a - various: /æ/ cat, /ɑ/ father, /ə/ apply
- b - /b/: bee, baby; silent: lamb, plumber, climb
- c - /k/: cat, coffee; /s/: city, cyan; (both in one word: success); silent: muscle; /ʃ/: liquorice
- ch - /t͡ʃ/: child; /ʃ/: cache; /x/: loch; /k/: school
- d - /d/: dog; /t/: jumped; /ɾ/: paddle
- e - various
- f - /f/: fish; /v/: of
- g - /ɡ/: gate; /d͡ʒ/: age; silent: gnome
- gh - /ɡ/: ghost; /f/: rough; silent: through
- h - /h/: hat; silent: hour
- i - various
- j - /d͡ʒ/: jet; /i/: fjord; /j/: Jugoslavia; /h/: Julio; /xw/: Juan
- k - /k/: kite; silent: knight
- l - /l/: lamp; /ɫ/ felt; silent: palm, walk; /j/: guillotine
- m - /m/: man; silent: mnemonic
- n - /n/: nose; silent: autumn
- o - various
- p - /p/: pet; silent: psalm
- ph - /f/: phone; /p/: diphthong, Phuket
- qu - /kw/: queen; /k/: plaque
- q - /k/: burqa; /t͡ʃ/: qi
- r - /ɹ/: red; silent: nurse
- s - /s/: stop; /z/: dogs; /ʃ/: sure; /ʒ/: unusual
- sh - /ʃ/: shop; /s.h/: mishap
- t - /t/: tap; /ɾ/: butter; /ʃ/: motion
- th - /θ/: thing; /ð/: this; /t/: Thames, Thailand
- u - various
- v - /v/: vain; /f/: Tchaikovsky
- w - /w/: wet; silent: write, sword, two
- wh - /w/: what; /h/: who
- x - /ks/: excel; /gz/: exit; silent: faux
- y - /j/: yellow; /i/: city
- z - /z/: zoo; silent: rendezvous
Some of these sound differences could be described as nuances, some seem quite different. It depends how different "different" is. Most letters have a primary sound, and a lifetime of exposure means an English speaker can correctly guess the pronunciation of unfamiliar words with a plethora of rules that are applied subconsciously.
For example, "b" is usually silent after "m". "c" is usually pronounced /s/ before the vowels "e", "i", and "y". "d" and "t" may be pronounced as /ɾ/ in quick speech (as opposed to careful speech), but is that different enough, or do you consider that sound to be an allophone of /d/ and /t/? As an example, Sinhala has a letter "ව" that supposedly represents the sound /ʋ/. However, native speakers pronounce it as either [v] or [w] depending on the word, and consider both sounds to be the same, even though they can be different in other languages, such as English.
A writing system where every word had to be learnt independently, would take a long time to learn. There would need to be a lot of pressure from some source to prevent it from simplifying or being replaced. It is said that Vietnamese writing is now a lot easier to learn now that the writing system is based on Latin letters instead of Chinese characters.
Since you've said in a comment that your motivation for asking is wanting to write a story, perhaps you should check out Worldbuilding.
I bring you: "The strange case of Mexican 'x'".
Letter 'X' in Mexican Spanish has four different sounds, and it takes some time for a non-native speaker to learn the nuances... Mostly, it's a matter of knowing the right pronunciation for each word.
- X can sound as you expect, /ks/ in words like "excluir" (exclude) or "extraño" (strange).
- Things start to be interesting when you pronounce "Mexico" in Spanish: you need to say /Méjico/ (say /Méksico/ and you may as well wear a T-Shirt saying "I'm a foreigner"). Same goes for "Oaxaca" and "Mexicali".
- It starts to get weird when you say "Xochimilco" (a borough in Mexico City): the "X" here has the sound /s/.
- And finally, if you say "Xola" (a metro station and a neighborhood in Mexico City), the "X" must sound /sh/ (don't say /sola/, which is the female form of "alone").
Hope this is an example of what you're looking for.
I am Mexican. I live in Mexico City. I know what I'm talking about.