Should be safe if the socket is a cigarette lighter size and rated at the current of one. I'd not connect an old fashioned battery charger that way, but the kind of charger sold as a conditioner does not charge at such a high current.
Do you have a voltmeter? You need to check the socket is always live, and not on position 1 of the ignition key.