How to convert a digital signal from 5V to 24V?
Converting to a "24 V signal" is missing the point.  The real problem is driving a 24 V relay from a 5 V digital signal.  Fortunately, that is easy.  Here is one way:



You didn't say how much coil current the relay draws at 24 V, so I picked an example part I had in my system (Zettler AZ8-1CH-5DSE).

Figure the B-E drop of Q1 is about 700 mV.  This means there will be 1 mA of base current when the left end of R1 is held at 5 V.  To guarantee the transistor stays solidly in saturation, let's say we only ask it for a gain of 20.  This means it can support up to 20 mA collector current.  13.5 mA is well below that, so no problem.

D1 is not optional, even though it looks like it doesn't do anything.  The relay coil has a significant inductive component.  When anything tries to shut off the current through it abruptly, the inductor will make whatever voltage it takes to keep the current flowing in the short term.  Without the diode, that would require abusing the transistor.  The diode gives the inductive kickback current a safe place to go while the current dies down on its own due to the resistance of the coil.

Added in response to your edit

I see you have substantially changed your question while I was writing this answer.  Your original question was better, because it simply asked how to do something.  That's easier to answer than having to first dispel myths.  I might have skipped this question entirely if I had seen it post-edit for the first time.

In any case, my answer above is still valid.  Using a opto-isolator is silly, since you don't need isolation nor a unpredictable voltage shift.  The ULN drivers are darlingtons, which have unnecessarily high saturation voltage.  You are also trying to use it as a high side driver.  Again, it's a lot more trouble to explain why a bad circuit is bad than to show a good circuit.  I'll therefore stick to my original answer.