The short answer is that heat is transmitted through space by radiation, but space has a temperature because it isn't truly empty. Or, better, it is not space that has a temperature at all, but the (very sparse) light and matter found in space.
Transmitting heat is not the same thing as having a temperature. You may remember learning in school about convection, conduction, and radiation as the three ways of transmitting heat. Convection, which is stuff that has heat moving around and carrying the heat to new places, does not work in perfectly empty space. Conduction, which is what you call it when rapidly jiggling atoms knock against their neighbors and make them jiggle faster, spreading the heat through the material, also doesn't work in empty space. But radiation, which basically means photons, can carry heat through perfectly empty space from one object to another. (By "perfectly empty", I mean "perfectly empty of matter", which I think is what you mean too.)
But you also ask a different question about how people can talk about the temperature of the space outside the atmosphere of a star. And the answer is that space is never completely empty, if you look on a large enough scale. Even between galaxies, there is estimated to be about an atom every cubic meter. And those atoms are moving. Since temperature is a measure of the energy of how much random motion there is, you can meaningfully assign a temperature to even the sparsest collection of atoms. You can also assign a temperature to the electromagnetic radiation, since photons have kinetic energy too.
Even though temperature has meaning in this case, it would do almost nothing to heat you up if you were out there. The interstellar medium can be immensely hot, but there is so little of it that the few atoms hitting you have essentially no effect, and you end up cooling off to near absolute zero by emitting radiation. This is similar to the way air at 450 degrees coming out of an oven is harmless to you, but you would burn yourself touching glass at the same temperature.
There are a lot of subtleties here. In a normal gas, atoms collide all the time, and so their speeds tend to get averaged out to be roughly similar. Some are slower and some are a good amount faster, but there's a formula for how many particles would be moving at a given speed that's different from the average. In space, they hardly collide at all, so those formulas don't apply. That changes the rules a bit, but people still find it useful to use the concept of temperature.