The Leviathan is first encountered when it swallows you during the mission "X Marks the Spot". After it swallows you, you'll fight Roscoe and Captain Scarlett inside of its stomach and then be coughed back up. You'll have found the hidden treasure room of Captain Blade but you'll have to fight the Leviathan to open it up. I highly recommend fire based weapons, particularly a sniper rifle and rocket launcher if possible.
The fight will start with you on a platform staring at the gigantic Leviathan. You'll see that it has two large blue eyes on either side of its head, another large blue spot over where its heart might be and one last blue spot on its "tongue" which is actually a large Sand Worm and possibly the actual core of the leviathan creature.
The Leviathan has a few simple attacks. It can spray you with a strange liquid which attracts Sand Worms, spit a substance at you that deals damage and resembles slag but without the status effect and it can burrow into the cliff face and throw rocks at you. The Sand Worms that appear will be mostly normal Sand Worms but later on, you'll encounter at least two Sand Worm Queens.
The main strategy is to save your rockets and use conventional weapons to aim for the eyes and the heart. After dealing damage to each, that spot will burst and you won't be able to deal damage any more. I prefer going for the eyes first because they are harder to hit and that will be compounded by far more Sand Worms later on if you start with the heart.
As you kill the three different spots, more Sand Worms will appear. You can kill them if you like but try to leave a few if you can because if you get downed, you want to be able to use one to come back. This is why you are saving your rockets, because when you go down, you can pull out your Rocket Launcher and blast one of the worms to get back on your feet quickly.
When all three spots have been destroyed, the Leviathan will sit quietly and not attack in any way. It will wait until you've killed every Sand Worm there is. Kill them all and a couple of Sand Worm Queens will also appear. Once you've killed two of those, the Leviathan will return to attacking but after attacking, it will generally stretch out the Sand Worm "tongue" that it has, allowing you to easily shoot the blue spot on its under side. More Sand Worms may appear at this point as well, allowing you to use them for a Second Wind again.
After each attack, look straight up and get ready to attack the tongue. When it appears, try and get as many shots as you can. After a few rounds like this, you should burst the blue spot and kill the Leviathan.