As Terran! I'm actually a huge noob and I have no idea if the other races can do this.
Inspired by watching a Reach(P) pro game a long time ago using an Archon targeting a Zealot to kill a Lurker
I made a quick video of this so you can see it in action:
WATCH IT IN 480P OR YOU WILL NOT BE ABLE TO SEE
Basically, since SC2 is a game running in a 3-D environment, cloaked units can be seen by panning your camera in and out. So you can easily tell (or just confirm) where an observer is by scrolling in and out. This is demonstrated in the first few seconds of the video.
Next, I order my Viking (Banshees are bad for this because of armor type) to park right on top of the Observer. Something interesting to watch, is that it also distorts the little green thing that point to where you order him to go, it is no longer a circle, but tuns into a big splotch, this is how you know you will be directly on top of it.
I then use my Thor (Air splash damage) to target the Viking, it takes to volleys to destroy the observer. Observe, the Observer, running away from the first volley, just watch the distortion and make your viking follow in its direction, you only need like half of the next volley to kill it off, so if you had 2 Thors it would be an instant Obs death.
If you have the right settings you don't need to pan your camera in and out to see cloaked units.
I don't really see this as practical. Just get a raven and save yourself a lot of health and time, or get missile turret if you're playing defensive. The only time I would recommend friend fire to take out a unit is ghosts or dark lots.
It isn't really suppose to be "pracitcal" I guess, not like you go around the whole map zooming in and out. If you see an obs, have a Thor and a Viking/Medivac, you can kill the obs without needing to waste the minerals on a turret that may not need to be there. The Thor doesn't even take the viking to half, so it can be quickly repaired.
IMO knocking out the Protoss map hacks for almost free is a good thing.
Also: (Duh) you could EMP it, but it would be best used on their Immortals/DTs and HTs.
You can use Hellions flame turret, park your unit above a creep tumour, attack your own unit, and it will kill the creep tumour. Same with banelings. Explode will damage a dark templar. All splash damage is like this.
Those setting would be at least medium, it makes it easier to see cloaked units. Even then it's not hard to point them out when you glancing across your screen. Especially when they are moving.
To the op the one killing thing here, you don't want observers even seeing anything. Hence you would want a missile or raven to kill it the instant it comes into range. Observers are really only expensive in the early stages.
It's a neat move if your really must kill it, but you would be served better by having proper detection, instead of doing something like this constantly.
To make it simple, please don't rely on this to get the job done.
More trouble than it's worth, and you should probably be using the time to macro or something. Or just get a turret/Raven. In any case, this is the wrong section. Moved to General.