Ferroelectric engineered pn doping in two-dimensional (2D) semiconductors hold essential promise in realizing customized functional devices in a reconfigurable manner. Here, we report the successful pn doping in molybdenum disulfide (MoS2) optoelectronic device by local patterned ferroelectric polarization, and its configuration into lateral diode and npn bipolar phototransistors for photodetection from such a versatile playground. The lateral pn diode formed in this way manifests efficient self-powered detection by separating ~12% photo-generated electrons and holes. When polarized as bipolar phototransistor, the device is customized with a gain ~1000 by its transistor action, reaching the responsivity ~12 A W-1 and detectivity over 1013 Jones while keeping a fast response speed within 20 μs. A promising pathway toward high performance optoelectronics is thus opened up based on local ferroelectric polarization coupled 2D semiconductors.