A backstab in Fallout 4 is simply a sneak attack using a melee weapon. It doesn't have to be done from the back, though it's much more difficult to pull off from the front.
Backstabbing can be done on any character, including your companions, or robots and synths (tested on Codsworth and Valentine).
Also, it can not be done with just any weapon, though I'm not too sure which weapons do work, and which weapons don't.
Weapons I've tested which don't work:
Weapons I've tested which work:
- Power Fist
- Shishkebab
- Ripper
- Combat knife
- Chinese officer sword