If you manage to get out of the city and fast travel somewhere else and wait a while before returning the inhabitants should return to being friendly. Or if you get inside a building and manage to open the wait interface before any of the hostile people get inside you can wait for most of the day and they should go back to normal. This doesn't work in Paradise Falls, though, as the Slavers like to hold a grudge. Also, there's a less effective option of holstering your weapon, this is even mentioned on the loading screens sometimes. But if you've already killed a few people everyone else probably wont stop attacking.