function sign(transaction, privateKey, sighashType, inputIndex, subscript, satoshisBN, flags, signingMethod) {
  var hashbuf = sighash(transaction, sighashType, inputIndex, subscript, satoshisBN, flags);

  signingMethod = signingMethod || "ecdsa";

  if (signingMethod === "schnorr") {
    const sig = Schnorr.sign(hashbuf, privateKey, 'little').set({
      nhashtype: sighashType
    });
    return sig;
  } else if (signingMethod === "ecdsa") {
    const sig = ECDSA.sign(hashbuf, privateKey, { endian: 'little' });
    sig.nhashtype = sighashType;
    return sig;
  }
}
Create a signature

@name Signing.sign
@param {Transaction} transaction
@param {PrivateKey} privateKey
@param {number} sighash
@param {number} inputIndex
@param {Script} subscript
@param {satoshisBN} input's amount
@param {signingMethod} signingMethod "ecdsa" or "schnorr" to sign a tx
@return {Signature}