There are several significant problems with trying this in reality, of which the biggest is heat. A ship's systems generate heat steadily, especially if it has human passengers who need life support. To keep from cooking, you have to get rid of the excess heat, and the only way to do that in a vacuum is via radiation. This makes your ship glow like a beacon to any infrared telescope. Worse still, most plausible space drive technology relies on spouting hot propellant into the void. That gives your location away instantly, and once you're spotted, you can't just turn off your engines to "go dark"—per Newton's First Law, your ship will keep going in the same direction at the same speed, which means it's easy to predict where you'll be. The only way to change direction and speed is to fire your engines again. Oops.
You can temporarily solve the first problem with a heat sink—a big block of ice or other cold material, into which you dump your excess heat. That can keep your ship at a livable temperature without external radiation. Unfortunately, the ice will eventually melt, and then you're back where you started. Moreover, you're still left with the second problem. Any attempt to maneuver will instantly reveal your presence unless you can find a way to keep your propellant cold while firing it out the back of a rocket.
On top of all that, there are various other issues. If you use any kind of active sensors (e.g., radar), you're sending out pulses of radiation that can be detected, so you have to rely on passive sensors only. And you can be detected by simple visual means, too. It's possible to see very small things at very great distances in space. Even if you paint your ship dead black, you can be spotted by the stars you occlude as you pass in front of them. You need an Invisibility Cloak of some kind (and you also need to be able to stick a sensor outside the cloak, or else you're flying blind).
If you really want Stealth in Space while staying true to science as we understand it, you need the following: 1.) A way to contain heat without giving off IR emissions. (Thermodynamics being what it is, this means your stealth mode has a time limit. Eventually you must offload your excess heat, or you'll fry.) 2.) A way to get your ship moving without generating hot exhaust, or at least generating it in a place where it won't be seen (behind a planet or something). Once you get moving, you can allow momentum to carry you to your destination—but any time you change course, you must eliminate or conceal those emissions, too. 3.) Some kind of cloaking technology to keep you from being seen directly. 4.) A willingness to operate with only passive sensors. If your cloaking technology does not allow you to stick a sensor through it, then you have to be willing to fly totally blind.
It should be noted that you can achieve "pseudo-stealth" much more easily. Detecting IR emissions and visible light reflections does not necessarily equate to any form of useful data. For example, if you approach with a star directly behind you, relative to your enemy (which is Rule #1 of the Dicta Boelcke, the rules for World War I fighter pilots), the enemy will have a hard time picking your radiation out from the radiation coming from the star. Stealth can also mean disguise, camouflaging your warship as a mining scow or delivery ship in a populated star system; or as an asteroid as long as you have your heat sink and don't need to make any turns. It's also possible to play terrain games: you can always hide behind something big, if you have the proper velocity to hold that relative position. Or for a big enough object one could land on or even inside it.
An obvious problem to approaches like this is that it only works if the ship, the natural object, and the observer you are trying to hide from all are in a straight line, so a defense against it is trivial: have two observers separated by a significant difference so that it's impossible to hide from both simply by using alignment. For trying to use a star as background, it would be difficult to maintain the illusion for a significant period of time even with a single observer because things move: something nearer to Earth than a star must move laterally in order to take into account Earth's orbit around the sun, or the planet or moon it's hiding behind, which means having to fire engines in order to adjust its position as those movements take place, which immediately gives up the game.
A final issue is asymmetry of resources: it is far easier and cheaper to deploy passive sensors far and wide in order to detect someone trying to sneak in than it is to be the one trying to sneak in, and if there's any technological parity then you must assume that the methods used to hide the ship can also be used to hide the sensors looking for the ship, and it's a lot easier to hide something sitting there passively looking into space and doesn't have to generate a lot of power to do so than it someone trying to actively sneak in, and so you can never be sure where all the sensors might be and therefore it's impossible to design a flight path to ensure you're obscured from view. Infrared isn't the only deal-breaker for stealth in space, so is basic geometry.
In an environment with Faster-Than-Light Travel (which automatically disqualifies it from realism), you can exploit the lightspeed limit. Since it takes time for the light your ship radiates to reach the enemy, if you can go faster than light, you can get there before you can be spotted. This is the basis of the "Picard Maneuver" seen in Star Trek: The Next Generation, one of the few places it was exploited. Likewise in softer settings where Faster-Than-Light Travel exists via the usage of Subspace or Hyperspace, stealth technology could be created by producing a means of remaining in the aforementioned alternate dimension while being able to see outside of it, against adversaries in normal space who cannot see you in return.
All of the above not withstanding, the point of stealth isn't necessarily to avoid being spotted - it's to avoid being spotted first. If space war ever becomes a thing, there will be measures taken to try to make it harder to be seen, regardless of how difficult this will be to do.
Some cases where stealth is at least possible, if not always plausible:
- Decoy balloons used in ballistic missiles - since all objects fall at the same speed in a vacuum regardless of mass, a balloon made of aluminum foil looks just like a warhead until it hits the atmosphere, making it harder to either predict the target or shoot down. That is, if and when anyone spends outrageous amounts of resources on orbital weaponry - such things were already possible in the 1980s, but how to make them efficient is a much more complex issue.
- The Misty series of spy satellites are thought to use a variety of stealth technologies to deflect ground based radar, lasers and sunlight away from observers on Earth. Unfortunately these technologies are not perfect and are only effective against observers within a specific directional cone allowing astronomy geeks in the free world to use occasional observations and orbital mechanics to keep good track of the stealth satellites' position. Another problem with the idea of a stealth satellite is that it would also need to be launched in secret with a stealth rocket. The former is hard to do and the latter is not possible economically (stealth materials and shapes would greatly reduce the rocket's efficiency).
- This also happens naturally. Earth-crossing asteroids are frequently discovered. These are capable of The End of the World as We Know It, so Earth has some reasons to pay attention, but astronomers have mapped only a small percentage of them. They asteroids don't use any fancy technology — just hunks of fairly cold rock in very very big space. Note that most of the problems are heat related, and asteroids are generally on the cold side. Also, asteroids are really, really small compared to all the other stuff Earth could be picking up on. It's like trying to find a frozen needle in a stack of burning hay. After literally billions of years in space, asteroids have no internal heat sources left (those that had any in the first place), but they still get warmed by the sun just like anything else at a comparable distance would. Of course, as asteroid detection methods go, infrared is probably still inferior to simply looking for reflected sunlight...