That Psalm is about questioning where God is in the present despite all the deeds He did in the past. When he brings up crushing heads of Leviathan, that’s just one of many things that’s being talked about. The verse before that said God split the seas with his might, which is a reference to Genesis.
But there isn’t a reference in the Bible for God literally slaying a multi-headed sea serpent. The Psalm isn’t retelling a Biblical story there, it’s using symbolism to show that God has overcome the chaos that’s infected the world.
But with that said, what I said about the reference in Job is merely a game theory.