Is it possible to reassign a contribution linked to a membership?
Through UI its bit difficult(impossible). If its a matter of single record then i would suggest you to use API explorer to do it.

Navigate to CiviCRM >> Support >> Developer >> API Explorer


Create Membership payment for old membership (23 is old membership id(without contribution) and 45 is contribution id)

Delete new membership.



  Note: Backup db before performing any api actions