Your sentences are dealing with the location of the water, so in a glass is correct.
Here is part of an A to Z preposition dictionary I have used for my esl writing and speaking classes for prepositions including in and with. It gives simple definitions and sample sentences or phrases for using them,
IN
1. Place thought of as an area: in London; in Europe
2. Within a location: in the room; in a building; in a cup / glass
3; large units of time: That happened in March, in 1992
4.By means of: write in pencil, speak in English
Note there are 9 definitions of the preposition in in the dictionary
WITH
1. Accompanying: He came with her; I have my keys with me.
2. Having ; containing: Here is a book with a map of an island.
3. By means of; using: I repaired the shoes with glue; I wrote that with a pencil
4. Manner: I did it with ease; with difficulty
Depending on context of sentence and the verb used prepositional use is sometimes confusing.
For your sentence see #2 in IN
Hope this helps
Ron
;
: