Project flat plane on node displacement object
Syncing displacement textures between two (or more) objects/materials is as easy as mapping to a single object.

First link the texture coordinate of the ocean object to the object itself like so





Then copy the Texture Coordinate, Mapping, texture and Displacement nodes to the material of the foam.



As long as you keep the Scale values of the mapping, texture and displacement nodes in the foam material the same as the values of their counterparts in the ocean material they should displace identically.

Further, if you need the foam to flatten toward the shore you can just use a colorramped gradient to ease between displaced water and the flat ground.