I am trying to design procedural spaceships for a game of mine, and I came across a similar problem, with the added issue that I needed to be able to generate irregular layouts (not bounded to a square or rectangular outline). My solution was as follows:
start with an empty square or rectangular map of tiles
generate random room center points; each point has a position and parameters for the room width and height; eg, a point at (13, 3) on the map that is the center of a room that is 8 * 2 tiles, thus tiles with a horizontal distance of 4 and a vertical distance of 1 will be inside the room.
move the room centers until they are spaced out by a specified hall width or they are adjacent; determine which to do by each room. eg, room 1 moves over until its edges/walls are at least 2 tiles apart from those of room 2
fill in the tiles above, below, or to either side of each room with hallways; choose which sides to fill in based on the position relative to the center of the map, eg a room up and to the left of the origin fills the space below and to the right of it with hallway tiles.
draw in the walls of both the house and each room, and doors where needed. First change any empty space tiles that border room or hallway tiles into walls. Then change any hallway tiles that border room tiles into walls.
So in theory it should look like this (periods are empty space, numbers are rooms, w is walls, h is hallways), although I haven't actually tried to implement it just yet; I apologize if this looks really bad in text I tried to make it look good:
(room one is 2x2 tiles, room 2 is 4x3, and room 3 is 3x2, hall width is four)
Step 1:
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
Step 2:
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . 1 1 . . . 2 2 2 2 . . . .
. . . . . . . 1 1 . . . 2 2 2 2 . . . .
. . . . . . . . . . 3 3 3 . . . . . . .
. . . . . . . . . . 3 3 3 . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
Step 3:
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . 2 2 2 2 . . . .
. . . . . . . . . . . . 2 2 2 2 . . . .
. . . . . . . . . . . . 2 2 2 2 . . . .
. . . . . 1 1 . . . . . . . . . . . . .
. . . . . 1 1 . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . 3 3 3 . . . . . .
. . . . . . . . . . . 3 3 3 . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
Step 4:
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . h h h h 2 2 2 2 . . . .
. . . . . . . . h h h h 2 2 2 2 . . . .
. . . . . . . . h h h h 2 2 2 2 . . . .
. . . . . 1 1 h h h h h h h h h . . . .
. . . . . 1 1 h h h h h h h h h . . . .
. . . . . . . h h h h h h h h h . . . .
. . . . . . . h h h h h h h h h . . . .
. . . . . . . h h h h 3 3 3 . . . . . .
. . . . . . . h h h h 3 3 3 . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
Step 5:
. . . . . . . w w w w w w w w w w . . .
. . . . . . . w h h h w 2 2 2 2 w . . .
. . . . . . . w h h h w 2 2 2 2 w . . .
. . . . w w w w h h h w 2 2 2 2 w . . .
. . . . w 1 1 w h h h w w w w w w . . .
. . . . w 1 1 w h h h h h h h h w . . .
. . . . w w w w h h h h h h h h w . . .
. . . . . . w h h h w w w w w h w . . .
. . . . . . w h h h w 3 3 3 w w w . . .
. . . . . . w h h h w 3 3 3 w . . . . .
. . . . . . w w w w w w w w w . . . . .
. . . . . . . . . . . . . . . . . . . .
from here you could add doors randomly in walls between rooms and hallways.
This would in theory be a great way to generate these ships, but I have yet to test it, and just in this example I noticed one potential unwanted artifact; there is one hallway space jutting out of the actual hall like this (capital H):
h h h h h w .
w w w w H w .
3 3 3 w w w .
3 3 3 w . . .
which is unwanted if you want rectangular hallways as well. A potential solution would be to take any hallway space surrounded on three sides by walls and replace it with a wall, and then remove all walls that are only bordering (including by diagonal) other walls and empty space because they are not necessary.
If you want a tile based solution, especially one not bound to a specific shape (although if you generate too many rooms in too small a rectangle they will spread outwards and become stuck at the edges in a rectangular shape, so make sure to generate a large enough map of empty space that the rooms won't hit the borders) then this should work :)