how do astronomers measure the angular position of a planet relative
to the Sun if the major observations are made during the night?
Modern astronomers don't need to "see" the Sun or the planets, as their positions are precisely known and constantly verified. It's therefore a fairly simple matter to determine when a planet returns to the same relative position in relation to the Earth and Sun (i.e. the synodic period). However, for ancient astronomers (or anyone without access to planetary ephemerides), other methods are necessary.
The simplest method is to define the synodic period as the time from one Sun-planet "opposition" to the next, an opposition occurring when the Sun and the planet form an angle of 180º as seen from the Earth. [See the image in this answer for what such an opposition looks like]. However, the challenge remains: when the planet is visible and approaching opposition, the Sun is likely to be below the horizon. How can you tell when they are at exactly 180º?
One solution is to wait until midnight. By definition, this is when the Sun is at its nadir, so any celestial object at its upper culmination (i.e. its highest point in the sky in a given 24-hour period) at midnight must be exactly on the other side of the Earth from the Sun (i.e. in opposition to the Sun).
The two problems with this method are that (a) you need a reasonably accurate way to measure the time so that you know when it's actually midnight, and (b) you need to be up and about at midnight. Well, not insuperable difficulties, even for the ancients....
If you're able to measure time relatively well, there's a more complex solution based on rising or setting rather than culmination. It involves plotting the movements of the celestial bodies along the ecliptic (in simple terms, the path the Sun takes across the sky). The ecliptic intersects exactly with due East and due West twice a year - at the equinoxes - but the ancient astronomers had a sophisticated understanding of its movement north or south at other times of the year. By noting how long after sunset it takes for a planet to rise, it's possible to work out the corresponding location of the Sun on the "great circle", and therefore what angle the two bodies form. If it's 180º, then they are in opposition.
I should add that the most obvious opposition is the Full Moon, the synodic period of which is 29.5 days (i.e. from one Full Moon to the next), as opposed to the sidereal period of 27.3 days (i.e. how long it takes for the Moon to return to the same position relative to the background stars).
This image shows how it works with the New Moon, but the principle is the same:
Source (and explanation)