Being able to switch between two damage types is a nice feature, but it doesn't have a severe impact on gameplay. If we look at this table, we can see that against radiant damage, there are barely any creatures with resistance or immunities, and those are probably good-aligned celestials you're never gonna fight unless you're playing an evil campaign. Vulnerabilities are also pretty much non-existant - in particular against radiant and necrotic - so there's no real advantage gained from that either.
So, conclusion 1: Being able to switch the damage type is certainly a balanced ability that is not too strong.
So, let's compare the damage of 1d6 radiant or necrotic that the weapon deals.
Looking at the Treasure section in the DM guide, we can find several weapons with similar damage values:
Frost Brand (p. 171), very rare: deals 1d6 cold, gives resistance to cold, sheds light in a 20ft radius, can extinguish nonmagical flames in a radius 1/day.
Sun Blade (p. 205), rare: finesse longsword that deals radiant instead of slashing damage; +2 to damage and attack rolls; +1d8 against undead; sheds sunlight in a radius (which is useful against vampires, drow or similar creatures)
Flame Tongue (p. 170), rare: bonus action to activate "fire mode", +2d6 damage on hit, sheds light.
So, if we compare 1d6 radiant or necrotic damage bonus to the values above, we could certainly make this weapon an uncommon or rare weapon.
Therefore, conclusion 2: Having a sword deal an extra 1d6 damage is within the realms of a balanced weapon. Depending on versatility and additional effects, a rarity of uncommon or rare would be appropriate.
Hence, taking the "Magic Item Rarity" table in the DMG, p. 135, into account (uncommon: PC lvl1+, rare: PC lvl5+), I would suggest something along the following lines, as opposed to just dealing extra damage:
Blade of Glistening Darkness, rare (requires attunement):
During your turn, you can use a bonus action to evoke one of the following effects, which lasts until you decide to end it (no action required) or until you spend one round without attacking. You also gain a +1 bonus to attack and damage rolls made with this weapon.
• Shadows start wreathing around the blade. While this effect is active, you have advantage on intimidation checks against any creature that is not undead. When you hit with an attack, you deal an extra 1d6 necrotic damage.
• The sword emits bright light within 5 feet of you and dim light for another 5 feet. This light counts as sunlight. When you hit with an attack, you deal an extra 1d6 radiant damage.
Blade of fickle Alignment, uncommon (requires attunement):
While attuned to this weapon, you can switch it from its necrotic to its radiant state and vice versa. During the short rest you use to attune yourself to the weapon, you have to decide on the initial state for the weapon.
When you hit with an attack made with this weapon, you can choose to deal an additional 1d6 damage of the weapon's current type.
Optionally, you can disable one of the respective effects for lawful good and chaotic evil characters, if you want to.
Anyhow, that's just my thoughts on the topic. You're the DM after all, though, so it's up to you to decide, we can only give you advice.
Addition due to OP's suggestion about the weapon "leveling up" as you do good deeds:
You could also use one of the "templates" above and as the wielder performs good deeds, the weapon gains "charges" - one maximum charge initially, and then an increasing maximum of charges the more good deeds are done ("good deeds" as defined by the DM). Those charges would be separate for each wielder. You can expend charges to deal an additional 1d6 damage per charge of the current type on a hit (you decide once you know if you hit). You regain charges on a long rest.
Such a weapon would definitely be rare or very rare, depending on which template you apply it to.
Feel free to change the size of the additional damage die, I'm not sure which value would be perfectly balanced. You could also scale the die with good deeds.
Example charge table:
Max charges | Regained after long rest
1 | 1 (i.e. all)
2 | roll 1d6, divide by 3, round up.
3 | roll 1d6, divide by 2, round up.
4 | roll 1d4