The dynamic emergence of cooperative norms in a social dilemma