#C, 165 <s>191</s> <s>189</s> bytes (full program)

Big thanks to O.O.Balance for suggestions and providing a [TIO][1].

    double atof(char*);main(i,v)char**v;{double x=atof(*++v);if(x<1e3)printf("%sB",*v);else{for(;x>=999.5;++i)x/=1024;printf("%.*f%ciB",2-(int)log10(x),x,"???KMG"[i]);}}

Save as `doit.c` and compile using `gcc -o doit doit.c -lm`, and run:

    > ./doit 1000
    0.98KiB

Test cases:

    > for i in 0 1 42 999 1000 1024 2018 10086 100010 456789 1023079 1023488 20080705 954437177 1084587701 1207959551 2147483647 ; do ./doit $i ; echo; done
    0B
    1B
    42B
    999B
    0.98KiB
    1.00KiB
    1.97KiB
    9.85KiB
    97.7KiB
    446KiB
    999KiB
    0.98MiB
    19.2MiB
    910MiB
    1.01GiB
    1.12GiB
    2.00GiB


  [1]: https://tio.run/##PctBC4IwAAXgvxIDYZvTNquDLBO6dIh@QXRYa7PBdKEmA/Gvt0Si43vvezKppAzh4d53q1aidxrKp2gx4rUwDTRkQEvGAx9/yBcLw3E8IG409HumNujVmqbXEETdERA8L8p2atSuhdwfijzP0x2PY4P8umA02/K/T7GOpJlPWQLnCllXMQo9Ip6AsizPlxO4mhvi0xRCYJTSj9RWVF1IbP0F