It is a matter of interpretation; therefore, you can decide as you see fit.
The first part of the description of the detect evil and good spell says:
For the duration, you know if there is an aberration, celestial, elemental, fey, fiend, or undead within 30 feet of you, as well as where the creature is located.
The question is therefore, if a point on the Ethereal Plane can be within 30 feet of a point on the Material Plane.
The description of the Ethereal Plane says, in part (DMG, p. 48):
[The Ethereal Plane's] “shores,” called the Border Ethereal, overlap the Material Plane and the Inner Planes, so that every location on those planes has a corresponding location on the Ethereal Plane.
You can therefore start with the distance on the 3 axes between the character location and the corresponding location of the hag on the ethereal plane. Then you need to consider the distance of the two 3D spaces (planes) on a fourth axis. Mathetically this can be calculated through a vector (4D) and its magnitude.
There is no numerical data in the DMG for the distance between the planes.
The definition of Truesight (MM p. 9; given to players by true seeing, PHB p. 284) states:
Furthermore, the monster can see into the Ethereal Plane within the same range.
Since no method of calculating the distance between the planes is given, it seems that it is ignored, i.e. the 3D distance between the material point and the corresponding point of the ethereal point on the material plane are used.
DMG p. 48 further states:
Conversely, the Ethereal Plane is usually invisible to those on the overlapped planes, except with the aid of magic.
This suggests that magical effects can à priori interact with the Ethereal Plane, although it says "invisible" so it is unclear if this applies only to sight (which detect evil and good is not).
In conclusion, it seems that the question of the distance is irrelevant if you rule that the rules for sight into the Ethereal Plane apply to detect evil and good, even if this is not actually about sight.