You can benefit if you watch Boyd Bushman's videos on youtube. He has probably accomplished gravity-less movement for his employer, the airplane manufacturer Lockheed Martin. He only gives you hints how to do it, if he tells the secret he loses his head! He suggests some simple experiments one can do to beat gravity and is always doing that with the help of magnets. As he says it so well, gravity is first cousin with magnetism. If you want to beat gravity, try moving magnets in some fashion.
It is probably the definition of your device (a pen) that is confusing. Be aware that many applications, called MAVs (Micro aerial vehicles), kinds of UAVs (unmanned aerial vehicles) already exist since many years and still R&D is going on. Please find enclosed such an example here: https://worldwide.espacenet.com/publicationDetails/biblio?CC=US&NR=2011278391A1&KC=A1&FT=D&ND=3&date=20111117&DB=EPODOC&locale=#
So, you are not the only one thinking of small flying devices... all the best!
The way to make a pen fly in vacuum is to throw it to the earth or other gravitating object and mis. It is a well documented method given in the "Hitchhikers guide through the galaxy". It is the trajectory that you choose.
Now you can make the surface of the pen covered with solar cells and you power with that an ion gun at the back. That would allow it to make the pen have some time of powered flight.
Okay, start with a hollow lightweight pen-shaped object with a tiny ink reservoir at one end, and the rest of the space unused.
You finish writing your note, flick a catch on your pen, and four sprung plastic arms pop out with little rotors on. Flick a second switch and the onboard battery makes the little quadcopter rise into the air.
You'd have to be careful stowing the sprung arms and rotor blades back into the body afterwards. Flight time would probably be severely restricted, but if it's not guided, you might not want it flying for too long in case you lose it. Have the rotors slow down at the end of the flight rather then just stop, so it lands gracefully. Probably a high risk of rotor damage from collisions with walls, etc., perhaps have four or six pop-out lightweight springy wire standoffs, so that the wire makes contact with a wall before the blades, and hopefully bounces the craft away.
The question is not as strange as it seems in the beginning. Assume you want to do measurement of some volume of space. You will need many measurement instruments that need to be brought up into space. We know the system of cube sat. Can we go further and make one cube sat to set out an armada of little pen shaped objects that become a controlled swarm? When you can make them do station keeping for some time then valuable measurements could be made.
To fall to the earth and miss is taken care of by the launch of the cube sat. Then we need only very little impulse for steering. How can we make micro rocket engines? In space most of the engines are single use.
We could make a circuit integrated on a chip with an array of pits. Each pit has two chambers isolated by a wall. They are filled with a combustible material and an oxidiser. By sending a small current through the isolation wall the heat will destroy the wall and ignite the chamber content. This results in a unit of explosion pressure in a given direction. I think a density of engine units of 100 per square mm is technically feasible. That are 10'000 pulses per square cm. The energy for one ignition can come from solar power or stored battery power. It should allow room for the scientific instruments and maybe some LED laser communication to the cube sat mother ship.
If you want to implement this don't forget to mention the source of the idea. You can ask me to help in the design.