Yes you can on a per leg basis.
Safest way to do it is keep your AA number in the booking to get seat selection, lounge invite, priority baggage etc.
Then when you are safely in the lounge ask the CX staff to remove your AA number, then add your BA number and print a new boarding pass.