function encode(_number) {
  let value = Math.abs(_number);
  const size = scriptNumSize(value);
  const buffer = new Uint8Array(size);
  const negative = _number < 0;
  for (let i = 0; i < size; ++i) {
    tools.writeUInt8(buffer, i, value & 0xff);
    value >>= 8;
  }
  if (buffer[size - 1] & 0x80) {
    tools.writeUInt8(buffer, size - 1, negative ? 0x80 : 0x00);
  } else if (negative) {
    buffer[size - 1] |= 0x80;
  }
  return buffer;
}
Encodes a number into a Uint8Array using a specific format.

@param _number - The number to encode.
@returns The encoded number as a Uint8Array.