I am looking for a way to sign a transaction manually by having the necessary input without using any libraries. I haven't found how the signing process exactly works anywhere hence why I am asking here. I do not want to use a library because I want to attempt and sign a raw transaction within Solidity without gas constraints.
EDIT: To clarify, I am not looking to broadcast the transaction to the network. I am simply aiming to return the signed message to the caller.