Can input parameter be optional and Python script tool work when input is not provided?

Like Jay said, you need to add logic to test whether each optional parameter was specified and take the appropriate action (or inaction) for each case.

Modifying your snippet above:

#SEWER#
sewer = arcpy.GetParameterAsText(0)

if sewer and sewer != "#":
    arcpy.AddField_management(sewer, "UID", "TEXT", 10, "", "", "", "NON_NULLABLE", "", "")
    arcpy.AddField_management(sewer, "Phot1_Link", "TEXT", 240, "", "", "", "NON_NULLABLE", "", "")

    #Calculate UID field
    fieldName = "UID"
    expression = "id_gen()"
    codeblock = """def id_gen(size = 9, chars = string.ascii_uppercase + string.digits):
    return ''.join(random.choice(chars) for x in range (size))"""
    arcpy.CalculateField_management(sewer, fieldName, expression, "PYTHON", codeblock)

The hash sign ("#") string is what the geoprocessing framework passes in for unspecified values so you have to look for that in addition to the empty/null string case.