I have a piece of floor that expanded and is popping up due to some water damage (attached photo).
Is it possible to just take out the piece and trim it down to make it fit? Or would I need to replace the entire floor?
You definitely do not need to replace the entire floor; the board is a different question. Typically repairing a hardwood floor involves splitting and removing one board before you can remove the adjacent ones from the tongue and grooves. Later you can replace the damaged board with the same species, or a leftover piece. (Occasionally you can pilfer one from inside a closet or remodeled space.)
That looks like a floating floor though, so you may be able to carefully prod that piece up and out. Possibly even undercut it a bit with a really fine trim saw or oscilating tool if you can get the entire side up.
Once you do have it out replacement is fairly straightforward. Cut away the bottom side of the groove and run a thin bead of adhesive along the adjacent tongue, then slide the board into place at an angle inserting the tongue into the place then pressing the half-groove down into the glue.