Yeah it can. Yes. Computers can see a difference between a gank and friendly play.
Legit places to kill another player would be anarchy systems, CZs, anywhere there's no law.
Whether you're ganking or being a pirate in a lawful area, having the law land on you for dusting another ship is quite realistic.
Realistic, yes. But this is a computer game, so the purpose is to be fun.
In-game punishments, therefore, need to be at least potentially fun for the player whose CMDR receives them.
So, to take a purely PvE example, you're in a RES, you get your targets confused and accidentally shoot one of the miners. 200 credit assault bounty on your head, all the nearby police ships head for you.
At the moment: fun - or at least potential fun - as you duck through the asteroids and get clear enough of the ring to hyperspace out.
Realistic: on your next docking in that jurisdiction your commander is arrested for assault with a deadly weapon and jailed for three years; please buy an alt if you want to keep playing before then.
The point of having all these crimes in the game is so that CMDRs can commit them, get away with them, and have a bit of fun evading the authorities in the process, so you're never going to get much more than a slap on the wrist for it, in the same way that trade is unrealistically profitable, combateers get an endless stream of incompetent NPC pirates to shoot if they choose (to collectively rack up millions of dead daily), mined goods pay out more according to the time spent mining them than to any realistic economic position that they could occupy, there's an endless stream of NPC mission givers offering to pay millions for something they could do themselves in five minutes, etc etc.
So there's no change that's going to be (or can be) made to the in-game legal system which is going to remotely deter people who want to from committing crimes, including PvP crimes.
If the behaviour is something that Frontier don't want
players to do, in-game punishments aren't appropriate. Instead, meta-game punishments get applied. Take for example shouting racist abuse at other CMDRs in the system chat, or using a cheat tool for infinite shields; that's against the EULA, it's reportable, Frontier reserves the right to make punishments up to banning you from the game completely if you're caught doing it. What you
won't get for it is a ten million credit bounty with the Federation for it, because that's not the appropriate way to handle that sort of behaviour.
Now, if what you want is for player-on-player violence to move from "a thing which the game mechanics allow" to "a thing which can technically happen but which is against the game rules except in very narrow circumstances", go ahead and suggest that specifically.