dnd 5th – Can you replace a racial trait when upgrading?

No, for two different reasons.

Most classes can not replace cantrips. Even wizards and wizards can only replace spells of one level for which they have spell locations, which excludes Cantrips since you do not have level 0 slots.

However, even if you could replace the cantrips, as can the unarmed incarnate Artisan, you still can not replace racial cantrips because your class abilities do not allow it.

The warlock class feature says, as you have quoted:

choose one of the warlocks you know

The catches you've won with your race are not warlock spells.

Similarly, the artificer's ability says:

you can replace one of the artificer's traps that you know

Again, race spells are not artificer spells.