Where to locate p trap and venting in complicated washing machine installation? See sketch
To do this right, you'll likely have to install a whole drain system for the washer.  You'll install a new vent (according to local codes), and a new drain line that attaches to the existing drainage system (in a code compliant way). Then you'll install a standpipe with a trap, that the washer can discharge to.