If you just wanted a small amount of flag wave I would recommend looking up displacement map tutorials. However the image you have linked to will need quite a bit of "hand" work. I would suggest using something like the image you show as a reference and then perhaps splitting the flag in to different segments (each on its own layer) and then using free transform / warp to make the flag follow the lines you want.
Just out of interest what flag do you want to look like the one in the linked image?
All a displacement map does is to distort the lines of an image based on a grey-scale value.
You could try to create your own reference image by taking the image you linked to and making a grey-scale image using a gradient fill to create the contours that you want. Then to use this as a displacement map. If you go down this route the advantage is that the same map could be used for different flag images. If you only have one flag to change I would probably go down the route of using Free transform and warp.