OTOH, a nuke doesn't need to yield several megatons. First devices were about 20 kilotons and it's possible to create smaller ones. I'm sure I've seen some video of 1 kiloton bomb. Also, intuitively, it doesn't seem that it would destroy a sub a few miles away looking at Baker test:
https://www.youtube.com/watch?v=5nWFx-zmI0k
Around 1:25 there's a brief fragment showing the explosion underwater with the usual expansion-contraction cycle.