Yes, the sector size is software-controlled, to a certain extent. Every FDC command involving sectors or tracks takes the sector size as a parameter. The size is specified as a bit shift applied to 128, so sector sizes are of the form 128 × 2n (usable values go from 128 to 4096 on the original PC; there isn’t enough time to fit an 8KiB sector in a track using the IBM PC’s single-density 5.25” drives). Sector sizes are assumed to be the same throughout a track.
As Tim Paterson explains, the IBM PC can write at most 6250 bytes per track in total (including gaps, which don’t store data). The headers and gaps result in an overhead of 114 bytes per sector, so a track can store 9 512-byte sectors, but not quite 10 — at least not safely, on all drives. (Since the tracks are circular, having gaps between the logical sectors isn’t sufficient, so counting 10 sectors and 9 gaps doesn’t work — a gap is also needed between the last and first sectors.) However it would technically be possible to store 5 1024-byte sectors, for a total capacity of 200KiB per side, 400KiB per disk. So while this addresses your question, it doesn’t explain why 512-byte sectors were chosen. 1024-byte sectors were used on other computers, and on IBM’s own 8” disks.
Later disk formats such as XDF and 2M used varying sector sizes to increase storage capacity, but they are more CPU-intensive and not appropriate for a 4.77MHz 8088. Some copy-protection techniques also relied on non-standard sector sizes.
See also What is between the sectors of floppy disks? for details of floppy disk layouts (in particular, their capacity needs to be considered in terms of reversals per unit of time, not bytes or anything like that).
Using larger sectors increases the memory requirements when reading from or writing to disks; DOS used two buffers by default on the PC, which would have meant going from 1KiB for buffers, to 2KiB. Larger sectors also reduces the data manipulation granularity, and 1KiB was a significant amount of data back then — two 512-byte buffers would have been more useful than one 1024-byte buffer.
As pointed out by supercat, duplicating equipment could have written disks with tighter tolerances and would have allowed higher capacities, for read-only distribution media. This was taken advantage of later on, with Distribution Media Format disks and the aforementioned XDF on 3.5” disks, but was apparently not considered for 5.25” disks.