You know the size of each ship.
Run a random number generator from 1 to # of squares of your grid.
When you get point, check if you have the required number of open squares that include your target point.
That is where your ship will be placed.
If you have multiple choices involving the target square, set up some random algorithm to reduce your choices.