The closer a body is to the Sun, the warmer it becomes.
Is it possible to find a certain trajectory around either the Sun or any star, on which the temperature is constantly between, for example, 20 and 60 degrees Celsius?
Yes, and no.
First of all: Space has no temperature.
There are no atoms to move, so nothing to have a temperature to be measured. However, any object in space will radiate its heat away very quickly. There simply isn't anything to stop it leaving, no insulation at all, so space "sucks" the heat energy from everything. For something that doesn't have a temperature, space is remarkably cold.
The biggest problem with temperature in space is not its absolute value; we can make hardware to operate from -80 to 120 degrees Celsius if we have to. The problem is temperature difference.
If one side of our imaginary spacecraft is exposed to direct sunlight it will start heating, while the side facing out into deep space will cool to almost absolute zero. This will put a massive temperature differential on the spacecraft which left unchecked would warp the structure, cripple the electronics, and generally be unhelpful.
So modern satellites use Thermal Control Systems to keep a constant (or at least managed) temperature throughout the craft.
Returning to your question:
Yes, it is possible to find an orbit that (depending on the design of the spacecraft) would provide an average (of the entire craft) temperature of between 20 and 60 degrees Celsius. However most of the craft would not actually be between those limits unless some thermal control system is implemented.
Ultimately it's a balancing act between energy in and energy out. Get that right and you can have a comfortable temperature anywhere.
take everything I'm going to say with a huge grain of salt. I'm just a guy who had the same question.
As stated, there is no medium in space against which to measure temperature, however you can measure incident radiation which is a kind of temperature in that too little of it and you will freeze and too much and you will get baked, and not in a good way. But that's only half the story, you also need to consider things like surface area, spin (which would allow a more even distribution of heat energy on the surface) and insulation.
What you want is to find a region around the sun where the outgoing heat energy through black body radiation of the object in question is balanced out by the incoming heat energy from the sun at the given temperature.
Just a warning, I'm going to be really ballparking the numbers.
For instance a human being produces about 100 watts of heat energy at rest. It also radiates away roughly 1000 watts in vacuum assuming a surface area of 2m^2 and body temperature of 300Kelvin (found using the Stefan-Boltzmann law. (This law works best if you assume the human being is a sphere.)) That means if you were butt naked in space, apart from the fact that you have much bigger things to worry about, you would want to be in a region of space where the incident solar radiation is about 900 watts to balance out what your body is radiating away plus what it is generating so there is zero net flow of energy from your body. That would put you somewhere between the orbits of Mars (700 watts) and Earth(1400 watts). You would want to be spinning too, otherwise the side of you facing the sun might be overheating as the side facing away freezes.
If you were in a space suit without thermal regulation, you would probably need to be even further away since they probably radiate much less heat, however you could make it so the suit reflected away almost all of the radiation making you both shiny and able to maintain ideal body temperature even closer to the sun.
That said, if you are in the shadow of something, you will freeze no matter how close to the sun. Even the night side of Mercury for instance which is very close to the sun goes down to nearly absolute zero since there is nothing to insulate it and hold on to the heat.
Again, take everything I say with a grain of salt.