try using bitcoin-tx that is included with bitcoin-core
you'll have to do all the calculations before you construct the tx
The following iswhat I learnt by trial and error, I couldn't find any documentation on this
bitcoin-tx -create in=TX_ID:INDEX outaddr=VALUE:ADDRESS set=prevtxs:'[{"txid":"TX_ID","vout":INDEX,"scriptPubKey":"76a914PUBLIC_KEY_HASH88ac"}]' set=privatekeys:'{"privatekeys":"PRIVATE_KEY"}' sign
The above can be used for a simple transaction which takes a single input and has a single output. The following values should be used as arguments.
TX_ID:INDEX - transaction hash and index of input
VALUE:ADDRESS - amount of BTC to be sent along with bitcoin address
PUBLIC_KEY_HASH - public key hash of bitcoin address from which BTC is being spent
PRIVATE_KEY - private key of bitcoin address from which BTC is being spent
When multiple inputs received by the same address need to be specified, there should be a "in=TX_ID:INDEX" argument that corresponds to each input. It has to be specified again under the prevtxs array. i.e. multiple {"txid":"TX_ID","vout":INDEX,"scriptPubKey":"76a914PUBLIC_KEY_HASH88ac"} arguments corresponding to each input seperated by commas within the square brackets. Multiple outputs can be specified by including "outaddr=VALUE:ADDRESS" corresponding to each output.
The output produced is the raw transaction as a string of hexadecimal characters.