How to calculate segwit transaction fee in bytes?
That depends on what those inputs and outputs look like.

The formula, as specified in BIP141, is:


Call base_size the number of bytes needed to serialize the transaction in legacy format (which does not include the witnesses).
Call total_size the number of bytes needed to serialize the transaction including witnesses.
The weight of the transaction equals 3*base_size + total_size
The virtual size of the transaction (which is what feerates are usually expressed against) equals weight/4 or 0.75*base_size + 0.25*total_size.


Some reference numbers:


Outputs:


A P2PKH (1... address) output is 34 vbytes.
A P2SH (3... address) output is 32 vbytes.
A P2WPKH (bc1q... address of length 42) output is 31 vbytes.
A P2WSH (bc1q... address of length 62) output is 43 vbytes.

Inputs:


A P2PKH spend with a compressed public key is 149 vbytes.
A P2WPKH spend is 68 vbytes.
A P2SH-P2WPKH spend is 93 vbytes.