The use of "ex" in the movie "Ex Machina" is not the same as the "ex" in "my ex-wife". The movie title is Latin, and means "out of the machine", although it's likely a reference to the literary phrase "Deus Ex Machina" meaning "God from the Machine".
(In classical Greek theater when the hero was in trouble at the climactic scene, a "god" would descend on a mechanism to come save him. In modern cinema it refers to any cliche or highly improbable means whereby the hero is saved from certain death. Many consider it a "cheap" trick, but it can be used in clever ways. How it relates to this particular movie, I'll leave to your interpretation.)
Otherwise you can use ex- with almost anything, to imply that thing is no longer part of your life. Although since "ex-" is most often used with "wife" it can imply that you once had a deep and significant relationship with that thing, with an unpleasant breakup:
A. I saw your friend Stephanie the other day.
B. Ex-friend, you mean. Stephanie and I are not on speaking terms.
For this reason I wouldn't usually say something like "my ex-dog", unless I really didn't like the dog. Similarly, "my ex-car" sounds like the car really let me down at some important moment, so it might be a funny thing to say.
A. Hey is that a new car?
B. Yes, my "ex" quit on me in the middle of the freeway, so I decided to start seeing other cars.
As far as humor goes, it's kind of clumsy. You would have to be pretty clever to make it truly funny (see StonyB's comment and the Monty Python link below for a classic example).