It's very simple, as your numbers don't get repeated. If first number is 0, just swap it with a value of random index. Here I have used index 3.
var arr = []
while (arr.length < 5) {
  var randomnumber = Math.floor(Math.random() * 10);
  if (arr.indexOf(randomnumber) > -1) continue;
  arr[arr.length] = randomnumber;
}
if (arr[0] === 0) {
  arr[0] = arr[3];
  arr[3] = 0;
}
console.log(arr);
.as-console-wrapper {top: 0; height: 100%;}
 
 
Testing to create 100 different cases:
var all = [];
var arr = [];
for (var i = 0; i < 100; i++) {
  arr = [];
  while (arr.length < 5) {
    var randomnumber = Math.floor(Math.random() * 10);
    if (arr.indexOf(randomnumber) > -1) continue;
    arr[arr.length] = randomnumber;
  }
  if (arr[0] === 0) {
    arr[0] = arr[3];
    arr[3] = 0;
  }
  all.push(arr.join(", "));
}
console.log(all);
.as-console-wrapper {top: 0; height: 100%;}