First, you need to install Microsoft's key.
On Ubuntu 20.04/22.04/24.04:
wget -q -O - https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null
Second, you need to add Microsoft's repository:
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf] https://packages.microsoft.com/repos/code stable main" >> /etc/apt/sources.list.d/vscode.list'
Update software:
sudo apt update
Install:
sudo apt install code