As far as I know, there are two possible uses of nuclear bombs: for mass destruction and for deflecting asteroids. For example, Wikipedia describes how nuclear bombs can be used for deflecting asteroids. Can those two things be achieved with the same bombs? Or must they be designed in different ways? Also, can nuclear bombs which are intended for mass destruction, be used to deflect an asteroid without making large adjustments?
Deflecting asteroids is far from the only proposed peaceful use of nuclear explosions, but few (if any) of them made economic, environmental, or political sense.
The answer is yes to your specific question as to whether existing nuclear weapons could be used for deflecting asteroids.
Specially designed "nuclear shaped charges" were proposed for Project Orion nuclear propulsion which could have been repurposed for asteroid deflection, but these were never built and do not exist (unless there is a government project that has been magically kept secret for decades :)). Neutron bombs were also proposed as better than regular nukes for "nudging asteroids" without blowing them up, but there has been no drive to develop dedicated neutron bomb asteroid deflectors.
The 2007 NASA report on "Near Earth Object (NEO) Mitigation Options Using Exploration Technologies" proposed using existing B83 bombs in a particular sequence. As @Tiger-Guy says, most nuclear asteroid deflection research assumes "bombs go boom" and works on figuring what sizes and sequences of standoff, surface, or subsurface explosions of existing Nuclear Explosive Devices (NED) will be most effective. As noted in the November 2020 AIAA ASCEND conference discussion of “Nuclear Devices for Planetary Defense” (PANEL-17):
The lack of need for new NED designs to handle the most probable future NEO threats is an important finding of the work to date on this topic
Nuclear bombs are nuclear bombs.
They are rated by how big the boom is, not anything else. Certainly no one is going to go design a bomb just for shooting it into space at a rock. Almost certainly the delivery veicle would be designed around an already existing warhead.