In principle yes, it can be done. It would be enough to put a MEMS accelerometer inside anything with an MCU and the rf component.
The device should work like an Inertial Measurement Unit (IMU) which might not be the simplest thing to do. Still you need to keep track of movements just for a few seconds and this can be done easily through simple integration, drifts and errors shouldn’t be nothing too high to be considered that much.
Adding a gyroscope(often inside the same MEMS) you can get full 3D orientation details.
Edit: you would then need to realize a usb dongle like any other wireless mouse to connect it to any computer