Can I use bitcoin-cli estimatefee API for Segwit?
size = 180 * len(inputs) * 34 * len(outputs) + 10


Unless you are using uncompressed keys (which very few wallets do today), this formula is wrong. It should be 148 instead of 180 as compressed keys are 32 bytes shorter than uncompressed keys.


  My question is that can I use bitcoin-cli estimatefee for weight?


No, you cannot. Bitcoin Core's fee estimation works on virtual size which is just the weight divided by 4. So instead you calculate the virtual size instead of the block weight and then you can use the fee estimate.