Transforms module documentation should help.
You can fit a plane to markup points as it is shown in this example in the script repository. You can modify the script to not set the slice plane but instead set the transform
What would you like to align? There is a module and code snippets available for brain AC-PC transformation.