“Live a good life. If there are gods and they are just, then they will not care how devout you have been, but will welcome you based on the virtues you have lived by. If there are gods, but unjust, then you should not want to worship them. If there are no gods, then you will be gone, but will have lived a noble life that will live on in the memories of your loved ones.”
No printed sources exist for this prior to 2009, and this seems to have been an attribution which arose on the internet, as indicated by web searches and rationales provided at "Marcus Aurelius and source checking" at Three Shouts on a Hilltop (14 June 2011) http://threeshoutsonahilltop.blogspot.com/2011/06/marcus-aurelius-and-source-checking.html
This quote may be a paraphrase of Meditations, Book II:
Since it is possible that thou mayest depart from life this very moment, regulate every act and thought accordingly.
But to go away from among men, if there are gods, is not a thing to be afraid of, for the gods will not involve thee in evil;
but if indeed they do not exist, or if they have no concern about human affairs, what is it to me to live in a universe devoid of gods or devoid of Providence?
But Gods there are, undoubtedly, and they regard human affairs; and have put it wholly in our power, that we should not fall into what is truly evil
Misattributed
Help us to complete the source, original and additional information
Marcus Aurelius 400
Emperor of Ancient Rome 121–180Related quotes

The Tragic Sense of Life (1913), VIII : From God to God
Context: And this God, the living God, your God, our God, is in me, is in you, lives in us, and we live and move and have our being in Him. And he is in us by virtue of the hunger, the longing, which we have for Him, He is Himself creating the longing for Himself.

“If you want to keep your memories, you first have to live them.”

Boston speech https://www.theguardian.com/uk/2001/jul/31/race.world1, The Guardian (August 1997)

“How you start your day is how you live your day. How you live your day is how you live your life.”
Source: Heal Your Body A-Z