In my experience, if you can change the FF number ahead of flight, preferably online, there would be no problem to have miles posted the way you want.
I did that with CO flights - some credited to AS, some credited to CO, on a r/t ticket.
You can also change it at the airport. Whatever FF number shown on the Boarding Pass, it would be that program your credit goes to.
One thing I do notice, no matter how you do it, you need to make sure the Boarding Pass reflect the CORRECT FF number in order to have credit posted properly.
If there is no FF number showing, and the FF program is a different one from the ticket stock - the airline would have to communicate with the ticket-issuing airline to make sure they do not post the credit, and until that verification is satisfied, your desired FF program would NOT post the credit - because airlines want to make sure no double credits are posted.