Liberal pedal use is stylistically and musically appropriate — even expected — in this music. (However, jump to the end for a spoiler: the piece can be convincingly interpreted non-legato where otherwise marked legato.)
For a general post concerning fingering options with wide intervals, see also
What is the best way to play a chord larger than your hand?
1. Use the pedal (see above), Granados himself can be heard pedaling in this measure.
2. Fingering options
Option A: 1-2-4; 1-2-5; 1-4-5 (My preference)
I would play C#4-G-C#5 1-2-4. This allows me to maintain a legato 4-5 when moving from C#5 to D5.
The main melody note — here the topmost notes — more important than the "supporting" notes in maintaining legato sound. Sliding the thumb here and/or using the pedal will cover any minor lapse of finger legato.
Having arrived at 1-2-5 on D4-G-D5, I would use the pedal to maintain my legato to the E4-G-E5.
Option B: 1-2-4; 1-2-(5 to 4); 1-3-5 (for finger-legato-with-no-pedal sticklers)
As in Option A, one can maintain a good enough legato by using 1-2-4 to 1-2-5 on C#4-G4-C#5 to D4-G4-D5. Where the present approach differs is that after arriving with finger 5 on D5, one immediately swaps in finger 4 for finger 5, thus freeing up finger 5 for a legato move to E5.
This does mean that finger 4 is not available for C#5 in the third chord, and for my hand, it's awkward to move from finger 2 on G4 to 3 on C#5 in a legato way.
Option C: 1-2-3; 1-2-4; 1-3-5 (for wider hand spans)
An excellent legato can be achieved if one's hand span allows for this fingering. It has the unique benefit (compared to Options A and B) that each finger, other than the thumb, receives a unique note. In particular, finger 3 is used for the initial C#5, so is already in place for the upcoming C#5.
Option D: 1-(2 or 3)-5; 1-(2 or 3)-5; 1-(3 or 4)-5 (for smaller hand spans)
This provides the least pure finger legato, but sounds perfectly fine will well executed pedaling. Which finger is chosen for the interior notes (G4 and C#5) is purely up to individual comfort and effectiveness.
Skillful pedaling is one's friend here. By applying the pedal with the downbeat chord, one can hold the pedal across the G5, releasing it with the arrival of the E4 (left hand) and F5 (right hand). (See below on who the pedal should be released rather than changed.) Done properly, there will be no sense of "blurring" of the sound, with the added benefit of a full and rich D2 on the downbeat.
Although not asked, the bigger problem is the second chord in measure 23. It's given in the question that 1-2-4-5 is the only option for this chord. As a consequence, there's no "truly legato" fingering available.
Hypothetically, one could play the preceding F5-E5 with 1-4, then the chord with 1-2-3-5, but that doesn't work here given the stated restriction.
To deal with this, apply the pedal as the left hand plays C#4 while the right hand is still playing E5. The latter point is critical, because if the E5 is released to early (or the pedal applied too late), there won't be a legato connection to the following chord's F5.
Again, one can hear Granados's use of pedal in this passage:
Pedal and Granados's recordings
One might object to my using Granados's recordings as examplars or pedal usage as the recordings are piano rolls which could have been hand adjusted (though perhaps more likely, IMO, to remove pedal than to add it).
In that case, I recommend Alicia de Larroccha. Note that while she uses pedal in both m. 9 and m. 22-23, the latter maintains no pretense of legato.