Everything depends on the bear, but there is no 100% sure. Grizzlies often shows aggression when protected, and if you show him that you are not dangerous (play dead), he may retreat. But it works not always.
However, black bears often attack as predators, so such a method does not take place in that case. If you have some food, then give it and try to go away slowly. If this method does not work, you need to loud sounds, trying to show a large bear (raise your hands, for example).