Returnal is a rogue-lite, and many things are locked away until you obtain them as permanent upgrades. Melee attacks are such an upgrade, which is found in the early game. You need to find this weapon to progress through the game.
To unlock melee attacks in Returnal, you first need to find the Sword, the Atropian Blade. Until you acquire this sword, it's not possible to melee, and you'll have to rely on your handgun in the early stages.
The Sword is located in the first biome, just following the main objectives, and you'll be tasked with destroying a Xeno-Tech barrier. To do this, you the Atropian Blade, because this is the only weapon that can destroy these red barriers.
Related: Returnal: When does the Game Save?
Due to the game's map-changing mechanics upon death, finding the sword can be arduous at best. The weapon is in the first biome, which is 100 percent guaranteed. Look for a huge red circular plinth, flanked by statues on either side. Nearby is a corpse in front of the plinth. Just keep an eye out for the Triangle icon to pick up the sword.
Do not worry. The sword, once acquired, is always with you, even if you die, because it is a key item, unlike other items on your person.