A hydrocarbon well system comprising a smart choke valve system that is configured to regulate flow of production fluid from a wellbore of a hydrocarbon well, the smart choke valve system comprising: a choke valve configured to operate at different choke settings to regulate the flow of production fluid from the wellbore; a sand sensor configured to sense amounts of sand production in production fluid flowing through the choke valve; and a choke valve control system configured to control operation of the choke valve, the choke valve control system configured to perform the following operations: obtain, from a well control system of the hydrocarbon well: a well profile for the well, the well profile comprising a sand production profile that defines a relationship of sand production of the hydrocarbon well to settings of the choke valve; and a first choke setting; control the choke valve to operate at the first choke setting; determine, based on the well profile, an upper sand production threshold that is indicative of a maximum amount of sand production for the first choke setting; determine, based on sand production measurements acquired by way of the sand sensor while the choke valve is operating at the first choke setting, a first amount of sand production of the well; determine whether the first amount of sand production is above the upper sand production threshold; and in response to determining that the first amount of sand production is above the upper sand production threshold: determine, based on the well profile, a second choke setting that corresponds to a second production flowrate that is less than a first production flowrate associated with the first choke setting; and control, in response to determining the second choke setting, the choke valve to operate at the second choke setting. a smart choke valve system that is configured to regulate flow of production fluid from a wellbore of a hydrocarbon well, the smart choke valve system comprising: a choke valve configured to operate at different choke settings to regulate the flow of production fluid from the wellbore; a sand sensor configured to sense amounts of sand production in production fluid flowing through the choke valve; and a choke valve control system configured to control operation of the choke valve, a choke valve configured to operate at different choke settings to regulate the flow of production fluid from the wellbore; a sand sensor configured to sense amounts of sand production in production fluid flowing through the choke valve; and a choke valve control system configured to control operation of the choke valve, the choke valve control system configured to perform the following operations: obtain, from a well control system of the hydrocarbon well: a well profile for the well, the well profile comprising a sand production profile that defines a relationship of sand production of the hydrocarbon well to settings of the choke valve; and a first choke setting; control the choke valve to operate at the first choke setting; determine, based on the well profile, an upper sand production threshold that is indicative of a maximum amount of sand production for the first choke setting; determine, based on sand production measurements acquired by way of the sand sensor while the choke valve is operating at the first choke setting, a first amount of sand production of the well; determine whether the first amount of sand production is above the upper sand production threshold; and in response to determining that the first amount of sand production is above the upper sand production threshold: determine, based on the well profile, a second choke setting that corresponds to a second production flowrate that is less than a first production flowrate associated with the first choke setting; and control, in response to determining the second choke setting, the choke valve to operate at the second choke setting. obtain, from a well control system of the hydrocarbon well: a well profile for the well, the well profile comprising a sand production profile that defines a relationship of sand production of the hydrocarbon well to settings of the choke valve; and a first choke setting; a well profile for the well, the well profile comprising a sand production profile that defines a relationship of sand production of the hydrocarbon well to settings of the choke valve; and a first choke setting; control the choke valve to operate at the first choke setting; determine, based on the well profile, an upper sand production threshold that is indicative of a maximum amount of sand production for the first choke setting; determine, based on sand production measurements acquired by way of the sand sensor while the choke valve is operating at the first choke setting, a first amount of sand production of the well; determine whether the first amount of sand production is above the upper sand production threshold; and in response to determining that the first amount of sand production is above the upper sand production threshold: determine, based on the well profile, a second choke setting that corresponds to a second production flowrate that is less than a first production flowrate associated with the first choke setting; and control, in response to determining the second choke setting, the choke valve to operate at the second choke setting. determine, based on the well profile, a second choke setting that corresponds to a second production flowrate that is less than a first production flowrate associated with the first choke setting; and control, in response to determining the second choke setting, the choke valve to operate at the second choke setting.