How do I convert a bone to b-bone with Python and set the number of segments
You cannot have specific bones as b-bones..it's all of them or none of them - the type is for the whole armature. You can have all as b-bones and set the segments to more than 1 only for the specific ones.

import bpy

bpy.data.armatures['Armature'].draw_type = 'BBONE'

bpy.data.armatures['Armature'].bones['Bone'].bbone_segments = 3